ios – 在dismissModalViewControllerAnimated之后调用popToRootViewControllerAnimated

前端之家收集整理的这篇文章主要介绍了ios – 在dismissModalViewControllerAnimated之后调用popToRootViewControllerAnimated前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在工作的应用程序,我调用presentModalViewController,一旦完成(调用dismissModalViewControllerAnimated:YES)它应立即调用popToRootViewControllerAnimated.

但问题是dismissModalViewControllerAnimated:YES工作正常,但popToRootViewControllerAnimated在它之后无法正常工作.

代码如下所示:

[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];

解决方法

尝试这样的事情:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self performSelector:@selector(patchSelector) withObject:nil afterDelay:0.3];


-(void)patchSelector{
  [self.navigationController popToRootViewControllerAnimated:YES]; 
}

它不是那么整洁但它应该工作.

更新:
你应该用

[self dismissModalViewControllerAnimated:YES];

代替

[self.navigationController dismissModalViewControllerAnimated:YES] ;

呈现模态的对象是视图控制器,而不是导航控制器.

原文链接:https://www.f2er.com/iOS/328258.html

猜你在找的iOS相关文章