问题描述
我正在使用Objective C处理iPhone应用程序。因为我需要同时关闭两个UIViewControllers,所以我使用下面的代码:
I am working on iPhone application using Objective C. As I need to dismiss two UIViewControllers at once, so I am using below code :
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
此代码在iOS6和iOS7中运行良好,但在iOS8中无效。我已经使用断点检查,我的ViewController viewDidLoad和viewWillAppear方法正在调用,但我的视图根本没有加载,所以作为输出,我得到空白的白色屏幕。任何人都可以帮助我,对于iOS8,我该如何解决这个问题,我是否需要使用presentViewController而不是presentViewController?
This code is working fine in iOS6 and iOS7, but it is not working in 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. Can anyone please help me that for iOS8, how can I solve this problem, should I need to use presentedViewController instead of presentingViewController?
推荐答案
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];
}];
}
这篇关于如何在iOS 8中关闭两个UIViewControllers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!