presentModalViewControllerAnimated 和 dismissModalViewControllerAnimated

使用presentModalViewControllerAnimated方法从A->B->C,若想在C中直接返回A,则可这样实现:

C中返回事件:

  • void back  
  • {  
  •       [self dismissModalViewControllerAnimated:NO];//注意一定是NO!!  
  •       [[NSNotificationCenter  defaultCenter]postNotificationName:@"backback" object:nil];  
  • }

    然后在B中,

    1. //在viewdidload中:  
    2. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(back) name:@"backback" object:nil];  
    3.   
    4. -(void)back  
    5. {  
    6.      [self dismissModalViewControllerAnimated:YES];  
    7. }  


    转载:http://blog.163.com/youthpasses@yeah/blog/static/161849228201251905220964/

  • 你可能感兴趣的:(presentModalViewControllerAnimated 和 dismissModalViewControllerAnimated)