UIAlertView在发布模式下导致崩溃 [英] UIAlertView causes crash in Release mode

查看:51
本文介绍了UIAlertView在发布模式下导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户转到相机时在我的应用程序中激活了帮助"选项,我将首先显示UIAlertView以及有关如何拍照的提示:

If the Help option is activated in my app when the user goes to the camera I show a UIAlertView first with tips on how to take a picture:

-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [actionSheet cancelButtonIndex]) {
    NSString *selectedButtonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
    if ([selectedButtonTitle isEqualToString:@"Camera"]) {
        // If Help is activated display camera tips
        if (helpEnabled == YES) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camera Tips" message:@"\n\n\n\n\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Go To Camera"];
            UIImageView *cameraHelpView = [[UIImageView alloc] initWithFrame:CGRectMake(17, 40, 250, 255)];
            UIImage *cameraTutorial = [UIImage imageNamed:@"Camera_Tips.png"];
            cameraHelpView.image = cameraTutorial;
            [alert addSubview:cameraHelpView];
                    [cameraHelpView release];       
            [alert show];
            [alert release];
        }
    }
}

这在调试"模式下有效,但在释放"模式下导致"EXC BAD ACCESS"错误.从这一点来看,我可以模态地呈现一个新的视图控制器,但是UIAlertView将始终使该应用程序崩溃.为什么?

This works in Debug mode but causes an "EXC BAD ACCESS" error in Release mode. I can present a new view controller modally from this point just fine, however the UIAlertView will always crash the app. Why?

推荐答案

我发现了我的错误.我没有将nil作为最终参数传递给otherButtonTitles!调试模式必须为您查看并修复此错误.希望这对某人有帮助.

I found my mistake. I wasn't passing nil as the final argument to otherButtonTitles! Debug mode must see and fix this error for you. Hope this helps someone.

这篇关于UIAlertView在发布模式下导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆