如何解除视图控制器并返回其父视图控制器?

时间:2013-08-29 09:42:19

标签: iphone ios objective-c presentmodalviewcontroller

我有一个带有XIB文件的另一个视图控制器的弹出视图。它从父VC(detailViewController)启动,但解雇代码在其自己的VC(KNThirdViewController

我正在使用此代码:https://github.com/kentnguyen/KNSemiModalViewController/blob/master/KNSemiModalViewControllerDemo/KNThirdViewController.xib

从(KNThirdViewController

调用时
- (IBAction)dismissButtonDidTouch:(id)sender {
    [self dismissModalViewControllerAnimated:NO];
}

该应用返回rootViewController而不是detailViewController。它应该简单地解除它自己(KNThirdViewController弹出VC)并将用户返回detailViewController

视图控制器显示为:

-(void)scriviBtnPress {

// You can also present a UIViewController with complex views in it
// and optionally containing an explicit dismiss button for semi modal
[self presentSemiViewController:semiVC withOptions:@{
 KNSemiModalOptionKeys.pushParentBack    : @(YES),
 KNSemiModalOptionKeys.animationDuration : @(0.5),
 KNSemiModalOptionKeys.shadowOpacity     : @(0.3),
 }];

}

2 个答案:

答案 0 :(得分:3)

试试这样:

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:NULL];

答案 1 :(得分:0)

在iOS 6.0中不推荐使用

dismissModalViewControllerAnimated:方法。为什么不尝试dismissViewControllerAnimated:completion: