I may be onto the wrong approach to transition one view to another in a view controller, but a bug I end up having is that the view can still detect touches while fading out.
Is there a way to tell your program to stop detecting touches globally easily?
-or-
Is there a better way for me to fade from one view to another? I expected there was a way to cache a picture of the old view, because I only need it for the effect, I don't need it to actually BE there active!
Right now a view controller method is being called, gotoIntro:
- (void)gotoIntro {
NSLog(@"switch to intro");
[UIView beginAnimations:nil context:NULL]; {
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:.5];
[UIView setAnimationDelegate:self];
for(UIView *v in [containerView subviews]) {
v.alpha = 0;
v.frame = CGRectMake(0, 0, 1024, 768);
[UIView setAnimationDidStopSelector:@selector(removeView:finished:context:)];
}
MainMenu *mainMenu = [[MainMenu alloc] init];
mainMenu.frame = CGRectMake(0, 0, 1024, 768);
[containerView insertSubview:mainMenu atIndex:0];
[mainMenu release];
}
[UIView commitAnimations];
} -(void)removeView:(NSString *)animationID finished:(NSNumber *)finished context:(void *)co开发者_如何学JAVAntext { NSLog(@"VIEW REMOVED"); [[self.view.subviews objectAtIndex:1] removeFromSuperview]; }
The previous view is set to index 1, which I wish I didn't have to do. Sorry I couldn't put the rest of the code in that box. Stack Overflow is broken.
Call [[UIApplication sharedApplication] beginIgnoringInteractionEvents]
and endIgnoringInteractionEvents
, respectively.
These lines will help you...
self.view.userInteractionEnabled = NO;
self.view.multipleTouchEnabled = NO;
self.view.exclusiveTouch = NO;
cheers..
精彩评论