2

我真的被这个迷惑了。我在我的应用程序中设置了两个 UIActionSheets。在您使用 UIActionSheets 中的取消按钮之前,它们可以正常工作。

当我离开页面时,UIAactionSheet 也会返回,它会使我的应用程序崩溃。

有没有人有任何想法,为什么?

-(IBAction) phoneButtonClicked:(id)sender
{
// open a dialog with just an OK button
phoneActionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                    delegate:self cancelButtonTitle:@"Cancel" 
                                                    destructiveButtonTitle:nil 
                                                    otherButtonTitles:[NSString stringWithFormat:@"Phone: %@",phone],nil];
phoneActionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[phoneActionSheet showInView:self.view];    // show from our table view (pops up in the middle of the table)
[phoneActionSheet release]; 
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

if (actionSheet == phoneActionSheet) {

    if(buttonIndex == 0){
            NSString *callPhone = [NSString stringWithFormat:@"tel:%@",phone];
            NSLog(@"Calling: %@", callPhone);
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
    }
}

}
4

1 回答 1

1

我建议不要在 phoneButtonClicked 中发布 phoneActionSheet。我怀疑您可能正在尝试使用错误的指针做某事。另一个很好的帮助是使用NSZombieEnabled

于 2010-05-12T14:04:00.723 回答