objective-c - wait_fences : failed to receive reply: 10004003 while displaying UIAlertView and home button pressed

标签 objective-c ios xcode

我已经搜索了与此相关的论坛,但没有找到有关此错误的信息。我在 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/

相关文章:

objective-c - iOS8 Xcode6 UICollectionView sizeForIndexPath : does not get called on rotation

objective-c - 我可以创建自己的内存管理来处理 Cocoa 对象吗

ios - 计算文件和数据存储采用IOS7

ios - UIScrollView 高度和宽度

iphone - 使用Xcode播放随机声音

iOS 8 : -[UIInputViewSet setRestorableResponder:]: message sent to deallocated instance 0x7d6659b0

javascript - 使用 Parse 3.0.0 定义 Parse Cloud 代码

ios - iOS 中的 GPS 模拟

ios - MPRemoteCommandCenter 禁用所有控件

iphone - UITableView : error after connected table view to datasource