2

可能重复:
iOS 应用程序在单击 UIAlertview 上的按钮后立即崩溃

在用户单击 UIAlertview 上的按钮后,我尝试使用电话应用程序拨打号码。手机应用确实打开了,但在单击 UIAlertview 上的按钮后,原始应用立即崩溃。有人知道原因吗?我确实试图确保我发布了应该发布的所有内容。错误是 0x3beb85b0: ldr r3, [r4, #8] EXC_BAD_ACCESS (code=1, address=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];
        }
4

1 回答 1

0

你可以尝试didDismissWithButtonIndex 代替clickedButtonAtIndex. 我猜让我知道。

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; 
于 2012-11-16T14:55:35.030 回答