1

I have some data that I want to switch between a table view and a map view. In the past I have just put everything onto one view controller. But I think this will get really messy because I will have many subviews for two separate views all on one view controller. So I would have to hide one view to edit the other. (Unless this is normal?)

I think my preferred option would be one view controller with 2 subviews, and here is what I have thought about so far...

  1. I tried using a view container, which separates out a UIView with an embedded segue, but it seems as though it can only have one segue connected to it, and I needed two (for table and map). It was hard to find good example material using this view container.

  2. I then thought about using nibs. I started IOS programming after storyboards, so I have never used nibs, yet, but this might be a good situation? Make two UIView nibs that can be loaded into the view controller.

  3. I could just use my one view controller, make two views inside it, one that holds all the table view subviews, and one that holds all the map view subviews. Like I said, though, this makes editing the view tougher.

So my question, what is a good way to create a view that uses the same data, but can toggle views without making the storyboard view controller bloated?

I thought about popping and pushing on the navigation stack as well to 'toggle' the views, but I think the views are on the same level, and the navigation stack doesn't make sense.

4

1 回答 1

1

我已将此作为指导来完全按照您的建议进行操作:

在不使用导航控制器堆栈、子视图或模态控制器的情况下动画视图控制器的变化?

我在故事板上创建了一个主要的UIViewController和另外两个UIViewControllers。我从情节提要中获得了一个控制器,并将视图转换为它并返回。我现在没有我的代码,所以如果这不能立即帮助你,我会编辑这篇文章,并在今晚晚些时候把我的代码放进去。

于 2013-05-09T14:03:45.250 回答