开发者

openURL: with a NSURL containing a formatted NSString isn't working

开发者 https://www.devze.com 2022-12-15 11:50 出处:网络
To open Google Maps with directions, i\'m using a formatted NSString inside a NSURL. But it doesn\'t work with [[UIApplication sharedApplication] openURL:nsurl];

To open Google Maps with directions, i'm using a formatted NSString inside a NSURL. But it doesn't work with [[UIApplication sharedApplication] openURL:nsurl];

code:

NSString * directionsURL = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%@&saddr=%@", @"Hartenseweg 16, Renkum", @"1 Infinte Loop, Cupertino"];
    [[UI开发者_如何转开发Application sharedApplication] openURL:[NSURL URLWithString:directionsURL]];


You need to use [NSString stringByReplacingPercentEscapesUsingEncoding:] to ensure you get a properly encoded string for a url.

0

精彩评论

暂无评论...
验证码 换一张
取 消