【问题标题】:openURL: with a NSURL containing a formatted NSString isn't workingopenURL:使用包含格式化 NSString 的 NSURL 不起作用
【发布时间】:2010-01-06 18:07:15
【问题描述】:

要打开带有方向的 Google 地图,我在 NSURL 中使用了格式化的 NSString。但它不适用于 [[UIApplication sharedApplication] openURL:nsurl];

代码:

NSString * directionsURL = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%@&saddr=%@", @"Hartenseweg 16, Renkum", @"1 Infinte Loop, Cupertino"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:directionsURL]];

【问题讨论】:

标签: iphone nsurl openurl stringwithformat


【解决方案1】:

您需要使用[NSString stringByReplacingPercentEscapesUsingEncoding:] 来确保您获得正确编码的网址字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    相关资源
    最近更新 更多