【问题标题】:Dismiss a Modal-Presented UITabBarController关闭模态呈现的 UITabBarController
【发布时间】:2013-01-23 21:28:55
【问题描述】:

编辑:添加了包含解雇的代码。

新数据

问题与旧数据下列出的问题相同,只是解雇线发生了变化。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if([title isEqualToString:@"Yes"])
    {
        NSLog(@"Calling Dismissal...");
        [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    }
}

正在调用函数,因为日志中显示“正在调用解雇...”。

当前层次结构:UITabBarController - NavigationController/NavigationController - View1/View2

旧数据

如果问题令人困惑,我会尝试关闭一个 UITabBarController,而不是我提出的模态。 UITabBarController 确实使用 NavigationControllers 来设置内部的两个视图。但是,不管我放了多少 parentViewController

(即):

[self.parentViewController.parentViewController.etc... dismissViewControllerAnimated:YES completion:nil];

UITableBarController 不会关闭。我在调用上面代码行的两个视图的 NavigationController 中放置了一个按钮。关于如何关闭 UITableViewController 的任何提示?

【问题讨论】:

    标签: objective-c uitabbarcontroller


    【解决方案1】:

    呈现视图控制器与父视图控制器的概念不同,需要将其关闭。这段代码:

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

    通常会成功。

    但是,根据这个控制器的功能,我通常更喜欢让我呈现的控制器向父级发送委托消息或NSNotification,以便父级可以在解雇之前提取它需要的任何数据。

    【讨论】:

    • 是的,我在 parentViewContoller 之前的代码中有它,它仍然不会关闭视图。我刚刚把它放回去再次测试它,仍然没有运气。虽然按钮正在调用该函数,但视图不会关闭
    • 在该行放置一个断点,然后在控制台中输入po selfpo self.presentingViewController。如果“self”是标签栏控制器,而“self.presentingViewController”是nil,那么您没有从另一个视图控制器呈现标签栏控制器,因此无法关闭它。 (视图控制器只有在出现时才能被关闭。)
    • 很抱歉,我的回复非常延迟,我正在考试中。我输入了po selfpo self.presentingViewControllerpo self(PitView *) $2 = 0x08c532b0 <PitView: 0x8c532b0>,它是一个 UIViewController。 po self.presentingViewController 提出了(UIViewController *) $3 = 0x00000000 <nil>,我认为这不是应该出现的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    相关资源
    最近更新 更多