[英]How to dismiss two UIViewControllers in iOS 8?
I am working on iPhone application using Objective C. As I need to dismiss two UIViewControllers at once, so I am using below code : 我正在使用Objective C处理iPhone应用程序。因为我需要同时关闭两个UIViewControllers,所以我使用下面的代码:
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
This code is working fine in iOS6 and iOS7, but it is not working in iOS8. 此代码在iOS6和iOS7中运行良好,但在iOS8中无效。 I have checked by using breakpoint, my ViewController viewDidLoad and viewWillAppear method is calling but my view is not loading at all, so as an output, I am getting blank white screen. 我已经使用断点检查,我的ViewController viewDidLoad和viewWillAppear方法正在调用,但我的视图根本没有加载,所以作为输出,我得到空白的白色屏幕。 Can anyone please help me that for iOS8, how can I solve this problem, should I need to use presentedViewController instead of presentingViewController? 任何人都可以帮助我,对于iOS8,我该如何解决这个问题,我是否需要使用presentViewController而不是presentViewController?
Swift code SWIFT代码
@IBAction func goBack(sender: AnyObject) {
var tmpController :UIViewController! = self.presentingViewController;
self.dismissViewControllerAnimated(false, completion: {()->Void in
println("done");
tmpController.dismissViewControllerAnimated(false, completion: nil);
});
}
- (IBAction)goBack:(id)sender { UIViewController *trmpVC = self.presentingViewController; [self dismissViewControllerAnimated:NO completion:^{ [trmpVC dismissViewControllerAnimated:NO completion:nil]; }]; }
Try following: 试试以下:
NSArray *arrVC = [self.navigationController viewControllers];
[self.navigationController popToViewController:[arrVC objectAtIndex:arrVC.count-2] animated:YES];
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.