UIAlertView在iOs 7上崩溃

时间:2014-01-22 22:50:06

标签: ios ios7 uialertview alert rating

当我的“gameover场景”第三次出现时,我有以下代码:

_alert = [[UIAlertView alloc] initWithTitle:@"Congratulations!!!\n\n"
                  "bla bla vla!"
                  message:NULL
                                           delegate:nil
                                  cancelButtonTitle:@"No, thanks"
                                  otherButtonTitles:@"Rate",@"Later",nil];
if (![settings boolForKey:@"ShouldNotRateLater"]) {
         [_alert show];
}

它开始在iOs 7上崩溃,并且在iOs 5或6中没有发生。

我已经尝试过了:

//[_alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES]; or

/*dispatch_async(dispatch_get_main_queue(), ^{
             [_alert show];
             [_alert release];
         }); */

这些是我在其他帖子中看到的提示,但它对我不起作用。

另外,运行NSZombie我得到了以下日志:

[UIImage isKindOfClass:]: message sent to deallocated instance 0x16da1dd0

有人知道我做错了吗?

非常感谢

3 个答案:

答案 0 :(得分:0)

我尝试了这样的代码并且有效:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations!!!\n\n"
          "bla bla vla!"
                                    message:NULL
                                   delegate:nil
                          cancelButtonTitle:@"No, thanks"
                          otherButtonTitles:@"Rate",@"Later",nil];
[alert show];

所以要么你的_alert被宣布为错误的方式(如@Ramshad所暗示的那样弱对强)或者你的![settings boolForKey:@"ShouldNotRateLater"]

有问题

请发布您收到的错误。

答案 1 :(得分:0)

@property设为strong而不是weak

@property(nonatomic,strong) UIAlertView *alert;

答案 2 :(得分:-2)

为什么在消息参数中使用“NULL”?该方法是期望和对象指针,所以如果你不想要任何消息,正确的方法是使用“nil”。 也许这就是你问题的原因。