두 개의 단추가있는 경고보기가 있지만 단추가 URL을 열지 않습니다. 나는 그 오류를 모른다. 도와주세요. 첫 번째는 사실이 아니다 경우에만 두 번째 발사를 원하기 때문에 당신이 당신의 두 번째 조건에 elseif
을 사용해야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 : 메소드와 추적. 반환되는 제목은 무엇입니까? 블록과 if 블록이 일치합니까? – TomSwift
make urre에 공간이 없습니다. –