gpt4 book ai didi

objective-c - 单击 UIAlertview 上的按钮后,iOS 应用程序立即崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:03:57 25 4
gpt4 key购买 nike

在用户单击 UIAlertview 上的按钮后,我尝试使用电话应用程序调用号码。电话应用程序确实打开了,但原始应用程序在单击 UIAlertview 上的按钮后立即崩溃。有人知道原因吗?我确实尝试确保我发布了所有应该发布的内容。谢谢!下面是代码:

-(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 = 0;
if(phoneLinkString)
{
[phoneLinkString release];
phoneLinkString = nil;
}
[message show];
[message autorelease];
phoneLinkString = [[NSString stringWithFormat:@"tel:%@",replace]retain];


}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
[self release];

message = nil;


if(message.tag == 0 && buttonIndex == 1){
NSURL *phoneLinkURL = [NSURL URLWithString:phoneLinkString];
[[UIApplication sharedApplication] openURL:phoneLinkURL];
}

- (void)dealloc {
[phoneNumberString release];
[phoneNumberLabel release];
[self release];
[message release];
[super dealloc];
}

最新代码

    -(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];
}

但点击 UIAlertview 上的按钮后它仍然崩溃。错误是 0x3beb85b0: ldr r3, [r4, #8] EXC_BAD_ACCESS (code=1, address=0x7269634f) 任何帮助将不胜感激。谢谢!

最佳答案

问题可能是您在 if 语句之前将警报设置为 nil。试着把它放在后面。

关于objective-c - 单击 UIAlertview 上的按钮后,iOS 应用程序立即崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13409981/

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