问题描述
我的应用程序具有offlineMapVC
和onlineMapVC
,以支持在线地图(使用MapKit和Google Maps)和离线地图(使用 Route-Me ).
I have a offlineMapVC
and a onlineMapVC
for my application to support both online maps (using MapKit and Google Maps) and offline maps (using Route-Me).
我制作了自己的mapVC
来管理这些mapVC的切换,并且能够将视图控制器用作一个单独的视图控制器.好吧,我通过在整个应用程序中使用新的mapVC
巫婆的offlineMapVC
和onlineMapVC
实例变量来完成此操作.
I made my own mapVC
to manage the switching of these mapVCs and be able to use the view controller as one separate view controller. Well I've done this by making the offlineMapVC
and the onlineMapVC
instance variables of the new mapVC
witch I now use all over my application.
首先,所有事情似乎都起作用,但是.但是,在长时间使用此方法时,由于在层次结构中使用View Controller,我遇到了一些问题. 我读到这是错误的方法. 是什么是管理两个视图控制器之间切换的正确方法吗?我的问题似乎很简单,但是我找不到合适的解决方案.
First off all things seem to work but. However while using this approach for a longer time I ran into some problems due my using of View Controllers in a hierarchy. I read this is the wrong way to go. What is the right way to manage the switching between two view controllers? My question seems fairly simple but I couldn't find a decent solution.
推荐答案
我本人将视图控制器放在视图控制器中,与我做相同的事情相比,我看到的程序员要好得多. (请参阅Rob Napier"iOS 5编程-突破极限."他经常提到.)只要您不止一个视图控制器直接控制相同的视图和子视图,就可以了.
I put view controllers in view controllers, myself, and I have seen much better programmers than me doing the same thing. (See Rob Napier "iOS 5 Programming - Pushing the Limits". He mentions it frequently.) As long as you don't have more than one view controller directly controlling the same views and subviews, you should be okay with it.
自从Jonah Williams撰写该文章以来,我认为iOS 5正式将视图控制器层次结构与自定义内容视图控制器一起使用.您可能会认为您的mapVC是自定义内容视图控制器,并实现了onlineMapVC和offlineMapVC作为子视图控制器.
Since Jonah Williams wrote that article, I think iOS 5 formalized the use of view controller hierarchy with custom content view controllers. You might consider your mapVC to be a custom content view controller and implement onlineMapVC and offlineMapVC as child view controllers.
(Apple文档链接往往会频繁更改,因此该文档的Google自定义内容视图控制器".)
(Apple documentation links tend to change frequenctly, so Google "Custom Content View Controller" for the documentation.)
如果您可以通过在两个视图控制器之间切换"来进一步说明您的意思,这将有助于回答您的问题.通常,我同时有多个活动的视图控制器.我不在他们之间切换. (我在同一应用程序中使用了导航和标签栏控制器,但我假设您知道它们的工作原理,并且您在问一个不同的问题.只是不清楚您的情况是什么.)
If you can give some more context to what you mean by "switching between two view controllers" that would help answer your question. Generally, I have more than one view controller active at the same time. I don't switch between them. (I use navigation and tab bar controllers in the same applicaiton, but I assume you are aware of how those work and you're asking a different question. It's just not clear what the detials are in your case.)
这篇关于使用View Controller管理其他两个View Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!