在谷歌地图iPhone应用程序中创建后退按钮
我正在使用这段代码来启动GoogleMapFine在谷歌地图iPhone应用程序中创建后退按钮,iphone,Iphone,我正在使用这段代码来启动GoogleMapFine -(void)buttonPressed:(UIButton *)sender{ NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude
-(void)buttonPressed:(UIButton *)sender{
NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];
}
当我点击按钮时,谷歌地图就会加载。此操作正在我的应用程序中。如何创建后退按钮?如果您是从应用程序中启动地图,那么最简单的方法就是在应用程序中使用。这将在导航栏中为您构建一个功能正常的后退按钮
如果你正在启动谷歌地图应用程序,那么你正在退出(或移动到后台)你的应用程序。这是不可能回头的。用户需要退出谷歌地图并手动返回到您的应用程序,方法是按下主页按钮并重新选择您的应用程序。如果您是从应用程序中启动地图,则最简单的方法是在应用程序中使用。这将在导航栏中为您构建一个功能正常的后退按钮
如果你正在启动谷歌地图应用程序,那么你正在退出(或移动到后台)你的应用程序。这是不可能回头的。用户需要退出谷歌地图并手动返回到您的应用程序,方法是按下主页按钮并重新选择您的应用程序。您可以使用导航栏和uiwebview进行查看。并在导航栏上放置“后退”按钮。谢谢。您可以使用导航栏和uiwebview进行查看。并在导航栏上放置“后退”按钮。谢谢。更好的方法不是使用
openURL
,因为它将退出您的应用程序,而是使用UIWebView
查看页面并将其推到UINavigationController
:
UIViewController *webViewController = [[[UIViewController alloc] init] autorelease];
UIWebView *uiWebView = [[[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,480)] autorelease];
NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude];
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
[webViewController.view addSubview: uiWebView];
[self.navigationController pushViewController:webViewController animated:YES];
这假设您已经在导航控制器中拥有要从中推送的视图。更好的方法不是使用
openURL
,因为它将退出您的应用程序,而是使用UIWebView
查看页面并将其推送到UINavigationController
:
UIViewController *webViewController = [[[UIViewController alloc] init] autorelease];
UIWebView *uiWebView = [[[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,480)] autorelease];
NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude];
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
[webViewController.view addSubview: uiWebView];
[self.navigationController pushViewController:webViewController animated:YES];
这假设您已经在导航控制器中拥有要从中推送的视图