UIAlertView デリゲートが呼び出されていません。アラートは表示されますが、ボタンが機能しません。1 つのボタンで Google マップを開き、もう 1 つのボタンでネイティブ マップ アプリを開きます。
-(IBAction)showAlertView {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Obrir en..."
message:@""
delegate:self
cancelButtonTitle:@"Millor no..."
otherButtonTitles:@"Mapes",@"Google Maps",nil];
[alert show];
}
-(void)showAlertView:(UIAlertView *)alert clickedButtonAtIndex (NSInteger)otherButtonTitles
{
NSString *title = [alert buttonTitleAtIndex:otherButtonTitles];
if([title isEqualToString:@"Mapes"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"http://maps.apple.com/?q=41.11670,1.25812";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];
}
if([title isEqualToString:@"Google Maps"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"http://maps.apple.com/?q=41.11670,1.25812";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];
}
}
@end