gpt4 book ai didi

ios - 警报 View 内的警报 View

转载 作者:行者123 更新时间:2023-11-29 04:31:13 25 4
gpt4 key购买 nike

第一个警报中的按钮会执行第二个警报,这基本上是调用某人的确认。我没有收到任何错误,但它不起作用。
当我按下第二个警报的“调用”按钮时,它崩溃了

-(void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

NSString *buttonString = [alertView buttonTitleAtIndex:buttonIndex];
if ([buttonString isEqualToString:@"Phone"])
{
UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Notice!" message:@"You are about to call .... Do you wish to continue?" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call", nil];
[alert2 show];

if ([buttonString isEqualToString:@"Call"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://12345678"]]];

}

if([buttonString isEqualToString:@"Website"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"website"]];
}

if ([buttonString isEqualToString:@"Facebook"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com/groups/..../"]];

}
}
}

最佳答案

您在第二个警报 View 中将委托(delegate)指定为 nil。这就是为什么 alertView:clickedButtonAtIndex: 委托(delegate)方法不会在第二次调用。因此,您应该将委托(delegate)指定为 self

    -(void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

NSString *buttonString = [alertView buttonTitleAtIndex:buttonIndex];

if([buttonString isEqualToString:@"Phone"]) {

UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Notice!" message:@"You are about to call .... Do you wish to continue?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call", nil];
[alert2 show];
}

if([buttonString isEqualToString:@"Call"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://12345678"]]];
}

if([buttonString isEqualToString:@"Website"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"website"]];
}


if([buttonString isEqualToString:@"Facebook"]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com/groups/..../"]];
}

}

我想这对你会有帮助。

关于ios - 警报 View 内的警报 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11720795/

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