viewdidappear not called on 2nd go round
I have view1 that when shaken will load view2 and in view2 a button is pressed loading view3, in view3 button is pressed loading view1. When view1 is loaded from view3 the shake gesture in view1 does not respond to shake any longer.
- (BOOL)canBecomeFirstResponder {
return YES; // making view the first resp开发者_StackOverflow社区onder for shake event
}
- (void)viewDidAppear:(BOOL)animated {
[self becomeFirstResponder]; //for the shake event
[super viewDidAppear:animated];
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion==UIEventSubtypeMotionShake) {
//adding AskAsh2VC START
AskAsh2VC *second = [[AskAsh2VC alloc] initWithNibName:nil bundle:nil];
//this will set the animation style to CROSSDISSOLVE!
second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:second animated:YES];
[second release];
//adding AskAsh2VC END
}
}
- (IBAction)goToAskAsh2VC: (id) sender {
// NSLog(@"Button WORKS!!!!");
//adding AskAsh2VC START
AskAsh2VC *second = [[AskAsh2VC alloc] initWithNibName:nil bundle:nil];
//this will set the animation style to CROSSDISSOLVE!
second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:second animated:YES];
[second release];
}
why don't u call view did appear on vc once you have presented it
[self presentModalViewController:second animated:YES];
[second viewDidAppear:YES];
From what you are saying, your view1 presents view2 modally... which means view1 never left, it is just obscured by view2 and all the subsequent views. And you are pushing multiple modal views which is generally frowned upon. It sounds like you would be better suited loading a navigationController and push each view onto the stack. When you want to reset back to view1, you can just popToRootViewController and kill everything off except for your first view.
The reason your shakes aren't being registered is because they are being captured by your hidden view controller.
精彩评论