【问题标题】:Present Modal View from UITabBarController从 UITabBarController 呈现模态视图
【发布时间】:2013-01-17 07:59:40
【问题描述】:

我使用故事板生成了一个新的选项卡式应用程序。

目前为止

标签栏控制器 -> 第一视图控制器 -> 第二视图控制器 -> 模态视图控制器

我试图在显示 tabBarController 之前打开模态视图。我在 AppDelegate.m 上添加了以下代码

showModalView 是从application:didFinishLaunchingWithOptions:; 调用的

- (void)showModalView
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    GSLoginViewController *loginView = [storyboard instantiateViewControllerWithIdentifier:@"loginView"];
    [loginView setModalPresentationStyle:UIModalPresentationFullScreen];
    [self.window.rootViewController presentViewController:loginView animated:YES completion:NULL];
}

这里是我的输出:

Warning: Attempt to present <ModalViewController: 0x93670d0> on 
<UITabBarController: 0x935d170> whose view is not in the window hierarchy!

【问题讨论】:

标签: ios uitabbarcontroller storyboard


【解决方案1】:

你得到这个是因为你的 Appdelegate 不知道 tabbarcontroller 是你的根视图。你应该尝试这样的事情。

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

并相应地添加您的代码。问题是您应该让应用代理知道 tabbarcontroller 是 rootviewcontroller。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多