У меня проблемы с простой анимацией.У меня есть UIImageView и невидимая кнопка поверх него.Когда эта кнопка нажата, изображение переходит в полноэкранный режим, когда пользователь нажимает в полноэкранном режиме, оно возвращается назад.Это отлично работает.Проблема в том, что при изменении размера изображения интерфейс блокируется (он не падает), он просто блокирует все взаимодействие с пользователем.Я не вижу, в чем проблема, хотя у меня есть теория, связанная с иерархией представления ...
Вот весь код для рассматриваемой анимации.
- (IBAction) imageButtonPressed {
NSLog(@"Entered imageButtonPressed method");
imageFullscreenView = [[UIImageView alloc]
initWithFrame:CGRectMake(8, 72, 72, 72)];
[imageFullscreenView setImage:[self.coolView image]];
[imageFullscreenView setContentMode:UIViewContentModeScaleAspectFit];
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
[mainWindow addSubview:imageFullscreenView];
// With Concurrent Block Programming:
[UIView animateWithDuration:0.5 animations:^{
[imageFullscreenView setFrame:CGRectMake(0, 0, 320, 480)];
imageFullscreenView.transform = CGAffineTransformMakeScale(1, 1);
imageButton = [[[UIButton alloc]
initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
[[[UIApplication sharedApplication] keyWindow] addSubview:imageButton];
[[[UIApplication sharedApplication] keyWindow]
addSubview:imageFullscreenView];
} completion: ^(BOOL finished) {
NSLog(@"entered First animation");
[self animationDidStop:@"Expand" finished:YES context:nil];
}];
}
- (void) animationDidStop:(NSString *) animationID finished:(BOOL)
finished context:(void *)context {
NSLog(@"Entered animationDidStop");
NSLog(@"animationID: %@", animationID);
if ([animationID isEqualToString:@"Expand"]) {
NSLog(@"Entered First if");
NSLog(@"imageButton enabled: %d", self.imageButton.enabled);
NSLog(@"coolButton enabled: %d", coolButton.enabled);
NSLog(@"uncoolButton enabled: %d", uncoolButton.enabled);
NSLog(@"reportButton enabled: %d", self.reportButton.enabled);
imageButton.enabled = YES;
imageButton = [[[UIButton alloc]
initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
[imageButton addTarget:self
action:@selector(didViewFullscreen:)
forControlEvents:UIControlEventTouchDown];
[[[UIApplication sharedApplication] keyWindow] addSubview:imageButton];
imageButtonPressed = NO;
} else {
}
}
- (void) didViewFullscreen: (id) selector {
NSLog(@"Entered didViewFullscreen");
[imageButton removeFromSuperview];
[UIView animateWithDuration:0.5 animations:^{
[imageFullscreenView setFrame:CGRectMake(8, 72, 72, 72)];
} completion: ^(BOOL finished){
NSLog(@"FINISHED");
//NSLog(@"imageButton enabled: %d", self.imageButton.enabled);
NSLog(@"coolButton enabled: %d", coolButton.enabled);
NSLog(@"uncoolButton enabled: %d", uncoolButton.enabled);
NSLog(@"reportButton enabled: %d", self.reportButton.enabled);
//[imageFullscreenView setFrame:CGRectMake(20, 72, 280, 192)];
imageFullscreenView.transform = CGAffineTransformMakeScale(1, 1);
[imageFullscreenView removeFromSuperview];
imageButton = [[[UIButton alloc]
initWithFrame:CGRectMake(20, 72, 280, 192)] autorelease];
[imageButton addTarget:self
action:@selector(imageButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
[imageButton setImage:nil forState:UIControlStateNormal];
[[[UIApplication sharedApplication] keyWindow] addSubview:self.imageButton];
}];
}