您的位置:首页 > 其它

使用presentViewController跳转到上上个页面,实现多层跳转的两种方法。

2015-10-09 21:38 561 查看
第一种方法
简单容易实现。
[self.presentingViewController.presentingViewController.presentingViewController
dismissViewControllerAnimated:NO
completion:nil];
一定要是no才行。

第2种方法:
转自http://blog.csdn.net/xiaofansong/article/details/8011557
pushViewController/presentModalViewController/addSubView区别及使用方法 - 一件飘雪 - 博客频道 - CSDN.NET
使用presentModalViewControllerAnimated方法从A->B->C,若想在C中直接返回A,则可这样实现:

C中返回事件:

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

然后在B中,
//在viewdidload中:  
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(back) name:@"backback" object:nil];  
  
-(void)back  
{  
     [self dismissModalViewControllerAnimated:YES];  
}
第二种方法  [self.presentingViewController.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil]; 一定要是no才行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: