Ios 为什么使用openURL打开谷歌地图找不到地址
我创建UITextView并设置文本=@中国,浙江省杭州市滨江区, 设置dataDetectorTypes=UIDataDetectorTypeAddress, 然后,长按,选择打开地图,就可以在谷歌地图中找到地址 但是,同一个地址,我用openUrl找不到地址Ios 为什么使用openURL打开谷歌地图找不到地址,ios,google-maps,openurl,Ios,Google Maps,Openurl,我创建UITextView并设置文本=@中国,浙江省杭州市滨江区, 设置dataDetectorTypes=UIDataDetectorTypeAddress, 然后,长按,选择打开地图,就可以在谷歌地图中找到地址 但是,同一个地址,我用openUrl找不到地址 NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", [address stringByAddingPercentEsca
NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
谁能告诉我为什么?或者我不使用这个urlhttp://maps.google.com/maps?q=%@你会尝试不同的重唱吗?例如,NSU编码
NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", [address stringByAddingPercentEscapesUsingEncoding:NSUnicodeStringEncoding]];
结果如何
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
?谷歌地图http://calls不使用%分隔符,而是使用+
NSString *fixedAddress = [fullAddress stringByReplacingOccurencesOfString:@" " withString:@"+"];
NSString *googleCall = @"http://maps.google.com/maps?q=";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[googleCall stringByAppendingString:fixedAddress]]];
一、 我自己昨晚遇到了这个问题,并用前面的代码修复了它。Hi,NSUnicoding不起作用,它是乱码,就像这个http://maps.google.com/maps?q=NÿþþÿÿÿÿþþÿþþV,ÿYmÿÿþÿÿþþÿÿþþÿÿÿ25,当我不使用任何编码时,openUrl不做任何操作。我用openUrl尝试了你的代码,它工作正常,正确地打开了滨江上的地图应用程序。在上面的代码中,您确定文本和地址的内容相同吗?该示例比我的应用程序中的地址短。它是浙江省杭州市滨江区南环路4280号元光德大厦5.楼502室. 在谷歌地图中可以找到UITextView中与UIDataDetectorTypeAddress相同的地址,但不适用于OpenURL。您可以复制中文并尝试