gpt4 book ai didi

ios - 在没有 Storyboard 的情况下在 AppDelegate 中设置 UIWindow

转载 作者:行者123 更新时间:2023-11-28 21:05:40 25 4
gpt4 key购买 nike

我正在努力建立一个没有 Storyboard的基本应用程序。我删除了 Info.plist 中的 Storyboard行,并在我的 didFinishLaunchingWithOptions 中设置了以下内容。

当我构建并运行时,我得到一个黑屏而不是全屏红色的模拟器。

我的 UIViewController 类除了 Xcode 在创建新项目时创建的样板之外没有任何内容

UIWindow * window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setBackgroundColor:[UIColor redColor]];
[window setRootViewController:[[ViewController alloc] init]];
[window makeKeyAndVisible];

知道我在这里做错了什么吗?谢谢

最佳答案

使用 self.window 不创建新窗口

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setBackgroundColor:[UIColor redColor]];
[self.window setRootViewController:[[ViewController alloc]init]];
[self.window makeKeyAndVisible];

关于ios - 在没有 Storyboard 的情况下在 AppDelegate 中设置 UIWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45848386/

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