我真的很喜欢这个。我在我的应用程序中设置了两个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]];
}
}
}
答案 0 :(得分:1)
我建议不要在phoneButtonClicked中发布phoneActionSheet。我怀疑你可能会尝试用坏指针做某事。另一个好帮助是使用NSZombieEnabled。