【问题标题】:dismiss view controller that was present on storyboard programmatically以编程方式关闭情节提要上存在的视图控制器
【发布时间】:2016-07-21 03:42:21
【问题描述】:

我有 3 个 ViewController,firstVCsecondVCthirdVC

firstVC 上,我有一个带有Present Modally segue 的按钮,它显示secondVC

secondVC 上,我有一个显示thirdVC 的按钮。

thirdVC 上,我有一个按钮可以关闭两个 VC(secondVCthirdVC)。

我试过这样做:

NSNotificationCenter 发布在secondVC 上调用此方法的通知:

-(void)dismissCalendarView
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

但它不起作用。

谢谢!

【问题讨论】:

    标签: ios objective-c cocoa-touch uiviewcontroller uistoryboard


    【解决方案1】:

    试试这个:

    self.presentingViewController?.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
    

    【讨论】:

    • 你能给我一个Objective-C的例子吗?
    • 这里是 Objective-C [[self presentingViewController]presentingViewController]dismissModalViewControllerAnimated:NO];
    【解决方案2】:
    [self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    

    试试这个。

    【讨论】:

      【解决方案3】:

      如果 FirstVC 是 rootviewController..

      [self.navigationController popToRootViewControllerAnimated:true];
      

      如果没有,

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-05
        • 2012-06-08
        • 1970-01-01
        • 1970-01-01
        • 2012-02-21
        • 2018-04-10
        • 2012-11-25
        • 2017-03-29
        相关资源
        最近更新 更多