gpt4 book ai didi

iOS 模拟器显示空白黑屏或白屏

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:31 24 4
gpt4 key购买 nike

我正在运行一个项目,完全没有问题,但第二个项目不会出现在 iOS 模拟器中。它显示的内容取决于我在 AppDelegate.m 中的 didFinishLaunchingWithOptions 方法中的内容。

黑屏:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}

给出白屏:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

有任何修复的想法吗?

最佳答案

如果您使用 .xib:

在第一种情况下,你看到黑屏是因为你甚至没有创建窗口,在第二种情况下 - 你创建了白色窗口,但没有根 Controller 。

需要指定窗口的rootViewController:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Your don't need specify window color if you add root controller, you will not see window because root controller will be above window.
//self.window.backgroundColor = [UIColor whiteColor];

self.window.rootViewController = [YourViewController new];

[self.window makeKeyAndVisible];
return YES;
}

如果你使用 Storyboard离开第一个例子:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}

并确保在 proj 文件中指定了主 Storyboard: enter image description here

还要确保将 Storyboard 中的 View Controller 之一设置为初始 View Controller : enter image description here

关于iOS 模拟器显示空白黑屏或白屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21205444/

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