0

我试图从表格视图单元格中打开我的应用程序中的地图,我知道我的 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 是用户的并直接指向上面的位置地址。

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

4

1 回答 1

0

您可以在该ViewController控件中的 didSelectRowAtIndexPath 中执行此操作TableView(而不是在 中AppDelegate)。使用您在该单元格中需要的数据(希望来自支持数据源)构建该 url,然后使用您上面的代码。像这样的东西:

NSDictionary *thisCell = [myTableViewData objectAtIndex:indexPath.row];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com.au/maps?q%@", [thisCell valueForKey:@"locationKey"]]]];
于 2012-08-20T10:04:55.580 回答