Я пытаюсь заставить свое приложение открыть приложение Apple Maps и получить адрес. Я пробовал это:
- (IBAction)openInMaps:(id)sender {
NSString *addressString = @"http://maps.apple.com/?q=1 Infinite Loop, Cupertino, CA";
NSURL *url = [NSURL URLWithString:addressString];
[[UIApplication sharedApplication] openURL:url];
}
и это :
- (IBAction)openInMaps:(id)sender {
NSString *addressString = @"http://maps.apple.com/?q=1_Infinite_Loop,_Cupertino,_CA";
NSURL *url = [NSURL URLWithString:addressString];
[[UIApplication sharedApplication] openURL:url];
}
Но кнопка просто действует так, как будто она ни к чему не привязана. Но это работает:
- (IBAction)openInMaps:(id)sender {
NSString *addressString = @"http://maps.apple.com/?q=Cupertino,CA";
NSURL *url = [NSURL URLWithString:addressString];
[[UIApplication sharedApplication] openURL:url];
}
Итак, всякий раз, когда это пространство, оно не работает. Как я могу открыть этот адрес?
stringWithFormat:
. Просто назначьте строку напрямую. - person rmaddy   schedule 13.02.2014