Ios5 这在iOS 5.1中可能吗?通过UIButton(+;操作)以编程方式将用户发送到地图?

Ios5 这在iOS 5.1中可能吗?通过UIButton(+;操作)以编程方式将用户发送到地图?,ios5,maps,uiapplication,Ios5,Maps,Uiapplication,我正在尝试使用NSURL将用户发送到带有我数据库地址的地图。我想在UIButton中的一个操作中实现这一点,就像我在电话、邮件和网络中所做的一样。像这样, - (IBAction)restActionWeb:(UIButton *)sender { NSString *urlString = [NSString stringWithFormat:@"http://%@",[restDetails objectForKey:@"Web"] ]; [[UIApplication sharedAppl

我正在尝试使用NSURL将用户发送到带有我数据库地址的地图。我想在UIButton中的一个操作中实现这一点,就像我在电话、邮件和网络中所做的一样。像这样,

- (IBAction)restActionWeb:(UIButton *)sender {
NSString *urlString = [NSString stringWithFormat:@"http://%@",[restDetails objectForKey:@"Web"] ];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}

对于像“美国加利福尼亚州我的小镇我的路123号,美国加利福尼亚州95472”这样的街道地址,是否可以这样做?

在一些变体中尝试了这一点,但没有任何运气

- (IBAction)restActionFind:(UIButton *)sender {
// Merge street + zip
NSMutableString *tempAdress = [NSMutableString string];
[tempAdress appendString:@"address://"];
[tempAdress appendFormat:@"%@",[restDetails objectForKey:@"Street"]];
[tempAdress appendFormat:@", %@",[restDetails objectForKey:@"Zip"]];
[tempAdress appendFormat:@", %@",[restDetails objectForKey:@"City"]];
[tempAdress appendFormat:@", USA"]; // Have this limitation in future?
self.restFindLabel.text = tempAdress;

// CHECK don't work, whats the url schema for address?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:tempAdress]];
}

希望它能像在你点击的某个文本字段中检测到en地址一样工作,然后进入带有该地址的地图并显示它

我认为使用方案B是一种“矫枉过正”的做法:这样使用CoreLocation+发送地址。它还利用了电池。我的意思是,我的数据库里有地址,只是想让地图显示出来

有什么建议或提示吗?谢谢!:-)

你试过这个吗

NSString *stringURL = @"http://maps.google.com/maps?q=123+My+Road,+MyTown,+CA+95472,+USA"];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
这意味着使用
http://
方案而不是
address://
,并依靠操作系统来理解它。在iOS6上可能无法正常工作,但在iOS5上应该可以正常工作


()

在链接中可以看到一些关于这方面的非常好的信息。谢谢。我可以给出两个正确的答案,这里有一个象征性的答案:√ ;-)谢谢,我没想到那个。现在,我们将把它作为一项工作。关于iOS 6-是的,我们也需要在应用程序中为此做好准备,在上面的评论链接中提供一些关于iOS 6的好信息……在iOS 6中,只需将
maps.google.com
更改为
maps.apple.com
即可将其发送到apple maps