用户如何从我的应用程序中的表格视图单元格中打开地图

时间:2012-08-20 09:10:50

标签: xcode map sdk uiapplication

我试图从桌面视图单元格中打开我的应用程序中的地图,我知道我需要在AppDelegate.m文件中使用此代码:

UIApplication *app = [UIApplication sharedApplication];

[app openURL:[NSURL URLWithString:@"https://maps.google.com.au/maps?q=Our+Lady+Queen+of+Peace+Catholic+Church+Greystanes"

我希望saddr成为用户并直接指向上面的位置地址。

如何将表格视图单元格链接到该代码?

1 个答案:

答案 0 :(得分:0)

您可以在ViewController中的didSelectRowAtIndexPath内执行此操作,该TableView控制AppDelegate(不在NSDictionary *thisCell = [myTableViewData objectAtIndex:indexPath.row]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com.au/maps?q%@", [thisCell valueForKey:@"locationKey"]]]]; 中)。使用您在该单元格中所需的数据构建该URL(希望来自后备数据源),然后使用上面的代码。像这样:

{{1}}
相关问题