У меня есть вид предупреждения с двумя кнопками, но кнопки не открывают URL-адреса. Я не знаю ошибки. Помоги пожалуйста.UIAlertView не работает
Вот код:
-(IBAction)showAlertView {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Obrir en..."
message:@"Es pot requirir la aplicació de Google Maps"
delegate:self
cancelButtonTitle:@"Millor no..."
otherButtonTitles:@"Mapes",@"Google Maps",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Mapes"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"http://maps.apple.com/?q=Plaça+del+Rei+43003+Tarragona";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];
}
if([title isEqualToString:@"Google Maps"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"comgooglemaps://?daddr=Plaça+del+Rei+43003+Tarragona&directionsmode=walking";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];
}
}
Ничто не выглядит явно не так. Попробуйте помещать контрольные точки в функцию 'alertVew: clickedButtonAtIndex:', чтобы точно видеть, что происходит – bengoesboom
Установите точку останова в вашем alertView: clickedButtonAtIndex: метод и трассировка. Какое название возвращается? Соответствует ли это и переходит в ваш блок (-ы)? – TomSwift
make usre url не имеет места. –