【发布时间】:2014-04-21 15:44:40
【问题描述】:
我觉得我在这里完全是个白痴,但我脑子里放了个屁,而且是 XCode 的新手。我有这段代码(如下)可以打开 Google 地图,让用户能够根据点击的按钮导航到特定的目的地。这是一个固定列表,在客场比赛旁边有一个导航选项,我是否正确地说我不需要新的视图控制器,因为谷歌地图应该只是在按下按钮时弹出?
我还需要在标题中创建一个IBOutlet 来创建按segue 的按钮。显然我不会将此代码放在- (void)viewDidLoad 中,因为我只希望它根据按钮按下来显示
- (void)getDirections {
CLLocationCoordinate2D start = { (startLatitude), (startLongitude) };
CLLocationCoordinate2D end = { (endLatitude), (endLongitude) };
NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}
【问题讨论】:
标签: ios google-maps navigation