Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is user interface blocked after animation?
    text
    copied!<p>I am having issues with a simple animation. I have a UIImageView and an invisible button on top of it. When this button is pressed the image goes full screen, when the user presses the full screen it goes back. That works fine. The problem is that when the image is resized back the interface gets blocked (it does not crash) it just blocks all user interaction. I can't see where the problem lies though I have the theory that is something related to the view hierarchy...</p> <p>Here is the entire code for the animation in question. </p> <pre><code>- (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]; }]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload