gpt4 book ai didi

iphone - UIActionSheet 取消按钮不断使我的应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 21:23:18 24 4
gpt4 key购买 nike

这个问题我真的很困惑。我在我的应用程序中设置了两个 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]];
}
}

}

最佳答案

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

关于iphone - UIActionSheet 取消按钮不断使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2819204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com