我正在工作的应用程序,我调用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] ;
呈现模态的对象是视图控制器,而不是导航控制器.