gpt4 book ai didi

iphone - 为什么在应用程序 :didFinishLaunchingWithOptions: causing an error? 中显示 UIAlertView

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

在我的应用程序第一次运行时,我向用户显示一个警告 View 以选择 iCloud 或本地文档存储。显示警报 View 会导致以下错误:

Applications are expected to have a root view controller at the end of application launch wait_fences: failed to receive reply: 10004003

为什么会这样?如何在启动时显示警报 View 而不出现此错误?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Check the user preferences for document storage options
if (![UserPreferencesHelper userDocumentStoragePreferencesHaveBeenCreated])
{
// User preferences have not been set, prompt the user to choose either iCloud or Local data storage
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Use iCloud?"
message:@"Would you like to store data in iCloud?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"No", @"Yes", nil];
[alert show];
}
}

**更新**

我应该提一下,我使用的是带有 Storyboard的 iOS 5。 Root View Controller 设置在 Storyboard中。

最佳答案

尝试将 [alert show] 替换为:

[alert performSelector:@selector(show) withObject:nil afterDelay:0.0];

这会延迟单次通过运行循环的警报,大概允许您的应用程序的 Controller 和 Storyboard在出现警报之前完成它们的设置。

关于iphone - 为什么在应用程序 :didFinishLaunchingWithOptions: causing an error? 中显示 UIAlertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9040896/

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