1

每当我的应用程序打开时,如果检查某些条件。如果失败,则会向用户显示 UIAlertView。

当执行 [alertview show] 时,构建在 xcode 4.4.1 崩溃中符合,因为它在 xcode 4.3.2 和 xcode 4.5 中运行良好。

这是代码

    NSString *appMessage = [NSString stringWithFormat:@"Error Message HERE"];
UIAlertView *appMessageAlertView = [[UIAlertView alloc] initWithTitle:nil message:NSLocalizedString(appMessage,@"Error Message") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"OK", @"ok"),nil];
appMessageAlertView.delegate = self;
[appMessageAlertView show];
[appMessageAlertView release];

错过了一个重要信息:崩溃发生在 iOS6

4

3 回答 3

0

试试这个,它会工作:

UIAlertView *appMessageAlertView = [[UIAlertView alloc] initWithTitle:nil message:@"Error    Message" delegate:self cancelButtonTitle:nil otherButtonTitles:@"ok",nil];
[appMessageAlertView show];
[appMessageAlertView release];
于 2012-09-25T10:09:57.950 回答
0

UIAlertView 的 delgates 方法在显示或关闭时被调用。所以添加

 <UIAlertViewDelegate> in .h 

再次它进一步崩溃

 delegate:nil in line 2

然后删除

appMessageAlertView.delegate = self;

 [appMessageAlertView release];
于 2012-09-25T09:42:44.393 回答
0

尝试设置标题字符串。

您的第一行也可以简化为: NSString *appMessage = @"Error Message HERE";

第 3 行也不是必需的,因为您已经在第 2 行设置了委托

如果您启用了 ARC [appMessageAlertView release];,则不允许。

你使用有什么原因otherButtonTitles吗?为什么不简单地设置cancelButtonTitleto NSLocalizedString(@"OK", nil)

于 2012-09-25T09:43:41.527 回答