【问题标题】:Cant launch Map from app on iOS 6 [duplicate]无法在 iOS 6 上从应用程序启动地图 [重复]
【发布时间】:2013-02-09 22:51:03
【问题描述】:

我正在尝试从我的应用程序中启动地图,我正在使用以下内容:

- (void) showMap:(id) button {
    UIApplication *application = [UIApplication sharedApplication];
    NSString *address = [((PhoneButton *) button).cell.client fullAddress];
    NSString *addressUrl = [NSString stringWithFormat: @"http://maps.apple.com/?q=%@", address];
    NSLog(@"Maps String: %@", addressUrl);
    NSURL *map_url = [NSURL URLWithString:addressUrl];
    [application openURL:map_url];
};

好吧,它不起作用。我试图找到问题,但看起来我做得对。那么,我错过了什么?

PS:我的地址格式是“800, Madison Ave, New York, NY”

【问题讨论】:

标签: iphone ios maps


【解决方案1】:

试试这个。

你的地址格式是这样的

“800, Madison Ave, New York, NY”

其中包含单词之间的空格。删除带“+”号的空格。您的最终到达网址应类似于以下网址。 有了这个,您可以在 iOS 6 上从应用程序启动 Map。

http://maps.apple.com/?q=800,+Madison+Ave,+New+York,+NY

【讨论】:

  • 好答案 +1 完美...
【解决方案2】:

网址不能有空格。空格和其他特殊字符需要正确转义。你想要:

NSString *escapedAddress = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *addressUrl = [NSString stringWithFormat: @"http://maps.apple.com/?q=%@", escapedAddress];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-07
    • 2014-09-02
    • 2020-07-16
    • 1970-01-01
    相关资源
    最近更新 更多