点击UIAlertview后,iOS应用程序崩溃了

时间:2012-11-16 14:45:34

标签: objective-c ios

  

可能重复:
  The iOS app crashed right after clicking the button on a UIAlertview

用户点击UIAlertview上的按钮后,我尝试使用手机应用程序拨号。手机应用程序确实打开了,但是原始应用程序在点击UIAlertview上的按钮后立即崩溃。有人知道原因吗?我确实尝试确保发布了应该发布的所有内容。错误是0x3beb85b0:ldr r3,[r4,#8] EXC_BAD_ACCESS(代码= 1,地址= 0x7269634f)任何帮助将不胜感激。谢谢!以下是代码:

    -(IBAction)dialButtonPressed:(UIButton *)numberButton
            {
            if ([company isEqualToString:@"Not Found"]==true){
                    message = [[UIAlertView alloc] initWithTitle:@"Sorry"
                                                                      message:@"No replace number found. Would you like to dial anyway?"
                                                                     delegate:self
                                                            cancelButtonTitle:@"No"
                                                            otherButtonTitles:@"Yes", nil];
                    message.tag = 1;
                    if(phoneLinkString)
                    {
                        [phoneLinkString release];
                        phoneLinkString = nil;
                    }
                    [message show];
                    [message autorelease];
                    phoneLinkString = [[NSString stringWithFormat:@"tel:%@",replace]retain];


                }
        }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
        {

            if(message.tag == 1 && buttonIndex == 1){

                NSURL *phoneLinkURL = [NSURL URLWithString:phoneLinkString];
                [[UIApplication sharedApplication] openURL:phoneLinkURL];
                message = nil;
            }
        }
- (void)dealloc {
            [phoneNumberString release];
            [phoneNumberLabel release];
            [super dealloc];
        }

1 个答案:

答案 0 :(得分:0)

您可以尝试didDismissWithButtonIndex而不是clickedButtonAtIndex。我想让我知道。

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;