为什么在应用程序中显示UIAlertView:didFinishLaunchingWithOptions:导致错误? [英] Why is showing a UIAlertView in application:didFinishLaunchingWithOptions: causing an error?
问题描述
在我的应用程序的第一次运行中,我向用户显示警报视图,以选择iCloud或本地文档存储。显示警报视图会导致以下错误:
On the first run of my application I show an alert view to the user to choose iCloud or local document storage. Showing the alert view causes the following error:
应用程序在
应用程序启动结束时应该有一个根视图控制器wait_fences:未能收到回复:10004003
Applications are expected to have a root view controller at the end of application launch wait_fences: failed to receive reply: 10004003
为什么会这样?如何在启动时显示警报视图而不会出现此错误?
Why is this happening? How do you show an alert view on start-up without getting this error?
- (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];
}
}
**更新**
我应该提一下,我正在使用iOS 5和故事板。根视图控制器在故事板中设置。
I should mention that I'm using iOS 5 with storyboards. The root view controller is set in the storyboard.
推荐答案
尝试替换 [alert show]
with:
[alert performSelector:@selector(show) withObject:nil afterDelay:0.0];
这会延迟一次通过runloop的警报,可能会让你的应用程序的控制器和故事板完成在提示警报之前设置它们。
This delays the alert for a single pass through the runloop, presumably allowing your app's controllers and storyboards to complete their setup before the alert is presented.
这篇关于为什么在应用程序中显示UIAlertView:didFinishLaunchingWithOptions:导致错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!