简体   繁体   English

按下按钮时如何从带有 PNG 图像的菜单切换到地图视图

[英]How to switch from a menu with a PNG image to a mapview when a button is pressed

I have created a my own background in photoshop and have imported it into my project.我在 photoshop 中创建了自己的背景并将其导入到我的项目中。 This image is the main menu of the project and it has 5 buttons on it.该图像是项目的主菜单,上面有 5 个按钮。 2 of the buttons are links and they work perfectly while the other 3 involve the app to switch views.其中 2 个按钮是链接,它们运行良好,而其他 3 个按钮涉及应用程序来切换视图。 Button 1 involves me creating a mapview but when I click the button in the simulator it comes out of the app.按钮 1 涉及我创建一个地图视图,但是当我单击模拟器中的按钮时,它会从应用程序中出来。

The code works perfectly on its own and it has the standard, hybrid and satellite views as well as map annotation.该代码本身完美运行,它具有标准、混合和卫星视图以及地图注释。

How do I code it that when I press the getlocation button in the main menu that it will jump to a mapview?我如何编码,当我按下主菜单中的 getlocation 按钮时,它将跳转到地图视图?

If it is a different view controller (ie another .h, .m, and .xib files), then use this code:如果它是不同的视图控制器(即另一个 .h、.m 和 .xib 文件),则使用以下代码:

MapViewController *vc = [[MapViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:vc animated:YES];

Or, if it is a UIView in the same view as your buttons, then use this code:或者,如果它是与您的按钮在同一视图中的 UIView,则使用以下代码:

[self.view bringSubviewToFront:mView];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM