我已经搜索了与此相关的论坛,但没有找到有关此错误的信息。我在 xcode 中创建了一个简单的单 View 应用程序,并添加了代码以在 viewDidLoad 方法中创建一个测试警报。
- (void)viewDidLoad
{
[super viewDidLoad];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert Test"
message:@"Alert Test"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
// Do any additional setup after loading the view, typically from a nib.
}
我没有添加任何其他代码。当我在我的 iphone 4 上运行它时,它运行没有任何问题。但是当我在显示警报的情况下单击 iphone 4 的主页按钮时,我得到了提到的错误。
设备:iphone 4 操作系统:iOS 5.1.1
请帮忙。提前致谢
最佳答案
你不应该在 viewDidLoad 中显示 alertView
, [UIAlertView show]
使用动画显示 alertView。当我们不在屏幕/ View 中时,我们应该避免动画性能,而是在 viewDidAppear
中显示 alertView
。
编辑:
-(void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss) name:@"UIApplicationWillResignActiveNotification" object:nil];
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
alert = [[UIAlertView alloc]initWithTitle:@"test" message:@"test" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
}
//do not forget to add this in your header
-(void)dismiss{
[alert dismissWithClickedButtonIndex:-1 animated:NO];
}
关于objective-c - wait_fences : failed to receive reply: 10004003 while displaying UIAlertView and home button pressed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12312542/