我在这里有此代码用于我的地图中的注释...
//alert view
if ([ann.title isEqual: @"Al-saidiya"]) {
NSString *msg=@"Phone No : 079011111";
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"Call Us", nil];
[alert1 show];
}
else if ([ann.title isEqual: @"Al-Kadmiya"]) {
NSString *msg=@"Phone No : 07902222222";
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"Call Us", nil];
[alert2 show];
}
else if ([ann.title isEqual: @"Palestine St"]) {
NSString *msg=@"Phone No : 0790333333";
UIAlertView *alert3 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: @"Call Us",nil];
[alert3 show];
}
else if ([ann.title isEqual: @"Karada Maryam"]){
NSString *msg=@"Phone No : 07905867";
UIAlertView *alert4 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"Call Us", nil];
[alert4 show];
}
else if ([ann.title isEqual: @"Mansour Office"]) {
NSString *msg=@"Phone No : 07954212";
UIAlertView *alert5 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: @"Call Us",nil];
[alert5 show];
}
else if ([ann.title isEqual: @"Hunting Club"]) {
NSString *msg=@"Phone No : 079337745";
UIAlertView *alert6 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: @"Call Us",nil];
[alert6 show];
}
else if ([ann.title isEqual: @"Al-jadriya"]) {
NSString *msg=@"Phone No : 07976231";
UIAlertView *alert7 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: @"Call Us",nil];
[alert7 show];
}
else if ([ann.title isEqual: @"Al-jamea'a"]) {
NSString *msg=@"Phone No : 07865323";
UIAlertView *alert8 = [[UIAlertView alloc]initWithTitle:@"Contact" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: @"Call Us",nil];
[alert8 show];
}
}
当我应用这种方法时::
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex==1){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://576576576"]]];
NSLog(@"It works!");
}
}
它已应用于上面的每个警报对象并采用相同的号码。我希望每个警报对象在我想打电话时都有自己的电话号码。