问题描述
我正在使用的应用程序中,我调用presentModalViewController
,一旦完成(调用dismissModalViewControllerAnimated:YES
),它应立即调用popToRootViewControllerAnimated
.
I am working application in which i calling presentModalViewController
and once finished(calling dismissModalViewControllerAnimated:YES
) it should immediately call popToRootViewControllerAnimated
.
但是问题是dismissModalViewControllerAnimated:YES
正常工作,但popToRootViewControllerAnimated
之后却无法工作.
But the issue is dismissModalViewControllerAnimated:YES
is working properly but popToRootViewControllerAnimated
is not working after it.
代码如下所示:
[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];
}
它不是那么整洁,但是应该可以工作.
It is not so neat but it should work.
更新:您应该使用
[self dismissModalViewControllerAnimated:YES];
代替
[self.navigationController dismissModalViewControllerAnimated:YES] ;
呈现模式的对象是视图控制器,而不是导航控制器.
The object that is presenting the modal is the view controller, not the navigation controller.
这篇关于在dismissModalViewControllerAnimated之后调用popToRootViewControllerAnimated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!