Objective c 在第二次循环时未调用ViewDid

Objective c 在第二次循环时未调用ViewDid,objective-c,ipad,ios4,Objective C,Ipad,Ios4,我有一个view1,当震动时将加载view2,在view2中按下按钮加载view3,在view3中按下按钮加载view1。从view3加载view1时,view1中的抖动手势不再响应抖动 - (BOOL)canBecomeFirstResponder { return YES; // making view the first responder for shake event } - (void)viewDidAppear:(BOOL)animated { [sel

我有一个view1,当震动时将加载view2,在view2中按下按钮加载view3,在view3中按下按钮加载view1。从view3加载view1时,view1中的抖动手势不再响应抖动

- (BOOL)canBecomeFirstResponder {
    return YES; // making view the first responder 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];
}

为什么你不在vc上显示你的视图呢

[self presentModalViewController:second animated:YES];
[second viewDidAppear:YES];

根据您所说的,您的view1以模态方式呈现view2。。。这意味着view1从未离开,它只是被view2和所有后续视图遮挡。你在推多模态视图,这通常是不受欢迎的。听起来您更适合加载navigationController并将每个视图推送到堆栈上。当您想重置回view1时,您可以只需打开OOTVIEWCONTROLLER并关闭除第一个视图之外的所有内容

没有注册Shake的原因是它们被隐藏的视图控制器捕获