我无法弄清楚如何在我的iPad应用程序的弹出窗口中打开Goog​​le地图。

目前,我得到的只是一个空的弹出窗口,并且该位置在野生动物园中开放。

这是我的代码:

MapViewController *map = [[MapViewController alloc] init];
UITableView *cell = [tableView cellForRowAtIndexPath:indexPath];

map.stringURL = [NSString stringWithFormat:@"http://maps.google.co.in/maps?q="];
map.stringURL = [map.stringURL stringByAppendingString:[arr objectAtIndex:indexPath.section]];
map.stringURL = [map.stringURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURL URLWithString:map.stringURL];
[[UIApplication sharedApplication] openURL:url];

popover = [[UIPopoverController alloc] initWithContentViewController:map];
popover.popoverContentSize = CGSizeMake(250, 250);
[popover presentPopoverFromRect:[cell frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

最佳答案

您所做的几乎所有事情都是正确的。但是您将URL发送到错误的对象。

在您的mapviewcontroller中,您可以拥有一个UIWebView并将该Webview的URL设置为您刚创建的URL。

在这里,您要求野生动物园启动并显示地图,实际上是退出您的应用程序来执行此操作。

更好,更像Mapkit的是,将显示一个viewview而不是在webview中显示一个地图。我建议您查看mapkit上的文档,并查看Apple的MapCallouts示例,该示例提供了很好的概述。

关于ios - 如何在ipad应用程序的弹出窗口中打开Goog​​le map ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9965444/

10-10 20:36