gpt4 book ai didi

ios - 从 UITabBarController 呈现模态视图

转载 作者:行者123 更新时间:2023-11-28 18:38:43 25 4
gpt4 key购买 nike

我已经使用 Storyboard生成了一个新的选项卡式应用程序。

目前为止

标签栏 Controller -> FirstViewController -> SecondViewController -> 模态视图 Controller

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

showModalViewapplication: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!

最佳答案

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

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

并相应地添加您的代码。问题是您应该让应用程序委托(delegate)知道 tabbarcontroller 是 rootviewcontroller。

关于ios - 从 UITabBarController 呈现模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14374494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com