0

アクションシートメソッドの下の行で EXC_BAD_ACCESS エラーが発生し続ける理由がわかりません。

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:numberFinal]];

コードを追加しましたが、なぜリリースされすぎたのかわかりません。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    number = [[results objectAtIndex:indexPath.row]objectForKey:@"phone"];

    number = [number stringByReplacingOccurrencesOfString:@"-" withString:@""];
    numberFinal = [NSString stringWithFormat:@"tel:%@",number];
    //tel:1234567890
    NSLog(@"NUMBER:%@",numberFinal);

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    UIAlertView *alert2 = [[[UIAlertView alloc]initWithTitle:@"Call" message:@"Call This Person?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil]autorelease];
    alert2.tag = kAlertViewTwo;

    [alert2 show];
   // [alert2 release];


}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if(actionSheet.tag == kAlertViewOne) {
        if (buttonIndex == 0)
        {
        }else{
        }
    }
    else if(actionSheet.tag == kAlertViewTwo) {
        if (buttonIndex == 0)
        {
            //ok button clicked - close alert  
        }
        else
        {
            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:numberFinal]];
        }
    }
}
4

1 に答える 1

0

行の前に NSLog を実行し、numberFinal を出力して、正常に割り当てられているかどうかを確認してください。

クラスが UIAlertView Delegate であることを確認してください

別の関数で同じコード行を試して、同じ問題が発生するかどうかを確認してください。UIAlertView クリック イベント内から sharedApplication にアクセスしている可能性があります。

それが役立つことを願っています:)

于 2012-08-19T03:58:08.880 に答える