マップの注釈用にこのコードがここにあります...
//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!");
}
}
それは上のすべてのアラート オブジェクトに適用され、同じ番号を取得しました。電話をかけたいときに、すべてのアラート オブジェクトが独自の電話番号を取得するようにします。