1

I'm building an app with the following page flows (it's a big complex so I will try to be as clear as possible):

Login -> MainViewController

Now, MainViewController uses controller containment in iOS 5 to host two views/controllers:

   MainViewController
     /               \
FirstController    SecondController --> DetailsController

From SecondController, I want to segue to a separate View Controller (you can think of it as "details" if you think of MainViewController as "master").

From SecondController, I can segue using "modal" segue to DetailsController. But when I "pop" back, iOS reloads MainViewController. I don't want it to do that.

If I use "push" segue, I get a runtime error saying there are no UINavigationControllers on the stack. Fine.

So what I tried next was I tried to make MainViewController the root controller of a new UINavigationController:

  Login --> UINavigationController --> DetailsController (but "initiated" by Second)
                   |
            MainViewController
              /               \
      FirstController    SecondController

And then from SecondController, I tell UINavigationController to perform the "push" segue. But I still get the same runtime error - no UINavigationController found.

I must not understand how the navigation stack works - it's probably not checking the caller, because I'm sure I'm calling performSegueWithIdentifier: from the UINavigationController.

I was using the "Your second iOS app" as a guide, and they prescribe this method (modal segue). But I really do not want to re-load the MainViewController if at all possible (it's doing some expensive things). I would prefer iOS to "cache" my view/controller/data. I could of course write code to cache my data when I load the details page, and reload the cache instead of re-computing the data when I pop back, but I was hoping the "push" segue would do this for me automatically.

If you guys have any ideas, I would be grateful. Thank you.

4

1 回答 1

0

为了使推送工作,您需要在 IB 中选择将进行调用的视图并将其嵌入到编辑器菜单中的导航控制器中。

编辑器 > 嵌入 > 导航控制器

于 2012-09-30T16:14:36.743 回答