首页 文章

解除模态视图控制器问题

提问于
浏览
0

我希望从已经嵌入导航控制器的视图控制器以模态方式呈现视图控制器,然后当用户按下完成按钮时,模态视图应该被忽略并且应该出现呈现视图控制器 .

以模态方式呈现视图控制器,我使用代码执行此操作:

@IBAction func openCardPreferences(sender: AnyObject) {
        let newVC = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("common") as CommonCardParametrsViewController

        self.presentViewController(newVC, animated: true, completion: {
        })
    }

但解雇模态视图控制器将我带回导航的控制器根视图控制器,而不是“呈现视图控制器”

@IBAction func applyChanges() {

        println(self.presentingViewController)
       // self.delegate?.doneButtonPressed?()

        self.dismissViewControllerAnimated(true, completion: {})
    }

正如您可能看到我尝试使用委托方法解除控制器,但这不能解决我的问题 .

有趣的是,日志 self.presentingViewController 返回 UINavigation controller 实例 .

我不明白发生了什么 . 我做错了什么?

1 回答

  • 0

    我将 UINavigationController 子类中的方法 setViewControllersviewWillAppear 移动到 viewDidLoad ,这解决了我的问题 .

相关问题