在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] ;
呈现模态的对象是视图控制器,而不是导航控制器。
如果你有一个带有UIViewControllers堆栈的导航控制器:
[self dismissModalViewControllerAnimated:YES]; [(UINavigationController*)self.parentViewController popToRootViewControllerAnimated:YES]; //UIViewController *vc = [[UIViewController new] autorelease]; //[(UINavigationController*)self.parentViewController pushViewController:vc animated:YES];
假设,该视图控制器中调用的模态视图控制器具有navigationController。
我想,你没有打电话给
[self.navigationController popToRootViewControllerAnimated:YES];
在目标模态viewcontroller中。 检查一下。
我遇到了类似的事情。 你需要首先复制你的self.navigationcontroller并保留自己,所以当你调用第二个pop时,仍然存在对NC的引用,你仍然存在。
// locally store the navigation controller since // self.navigationController will be nil once we are popped UINavigationController *navController = self.navigationController; // retain ourselves so that the controller will still exist once it's popped off [[self retain] autorelease]; // Pop this controller and replace with another [navController popViewControllerAnimated:NO]; [navController pushViewController:someViewController animated:NO];
请参阅: 如何从UINavigationController中弹出视图并在一次操作中将其替换为另一个视图?
- 以编程方式在ios上创build快捷方式
- NatCam教程系列1:开始
- iOS – 正确格式化mySQL(apache)和iOS(NSDate)之间的时间戳
- AudioFileSetProperty返回'kAudioFileUnsupportedPropertyError(pty?)'
- 使用UIScrollview可以使用UIAnimator的UISnapBehavior?
- Swift:在iOS8中旋转一个button?
- 使用淡入淡出animation呈现模态视图
- Xcode 7debugging输出:“错误:177:超时… mMajorChangePending = 0”
- 如何在Swift中从相机或照片库加载图像