gpt4 book ai didi

ios - 单 View 应用程序具有无法更改的黑色背景

转载 作者:行者123 更新时间:2023-12-01 17:46:45 25 4
gpt4 key购买 nike

我正在使用 objective-c开发针对 11.4 iOS 的单 View 应用程序,以及 Xcode版本是 9.4.1。

创建后有Main.storyboard和LaunchScreen.storyboard,我把Main.storyboard的背景改成了黄色。

然后加载rootViewController用打击代码片段:

self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];

当我运行应用程序时,应用程序的背景是黑色而不是黄色,这是怎么回事?

=========================
添加截图:
enter image description here

=========================
为 init rootviewcontroller 添加代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen alloc] bounds]];

self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

========================
我可以确认是 didFinishLaunchingWithOptions 中的代码失败,如果我在方法中注释掉这些代码,一切正常,不知道为什么。

最佳答案

您无需触发任何代码即可获得 Main.storyboard初始 View Controller 。

删除代码并转到Project settings -> General tab在这里你会找到Main Interface查看是否设置为Main (您的 Storyboard名称)

enter image description here

也检查你的storyboard入口点设置为您想要的viewcontroller或不。

enter image description here

运行您的项目并查看。

关于ios - 单 View 应用程序具有无法更改的黑色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51242379/

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