0

嗨,我尝试使用它打开具有当前位置的地图应用程序,并获取我为方向输入的任何内容的方向。当我单击 iPhone 上的按钮时,没有任何反应,但它被单击了。我究竟做错了什么?

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=Current+Location&daddr=%@ %@ %@ %@",
                     streetString , cityString, stateString, zipString];
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
4

1 回答 1

0

Make sure you're escaping the the NSString using stringByAddingPercentEscapesUsingEncoding

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/mapssaddr=Current+Location&daddr=%@ %@ %@ %@", streetString , cityString, stateString, zipString];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
于 2012-06-18T18:06:23.847 回答