I've read a lot of questions regarding this issue but still I couldn't find a proper solution to this problem. I have a news application that starts on a Splash Screen (To fetch the news feeds and cache them) then it switches to the main screen which is a mash-up of news articles. You can navigate from this screen to many other screens by clicking on the articles, sections, galleries, videos, etc...I have a fixed header and a footer which I decided to subclass a master UIViewController and place those on that (I'll inherit this UIViewController in my other UIViewControllers)
I've read that the best way to do this is by having multiple view controllers each controlling a specific section of my application. However I'm still a bit confused about how to switch between those properly and responsibly. I tried the storyboard segues but I ran into two problems:
- I need to create a lot of segues since you can virtually jump from any screen to any other screen
- The segues will not preserve the state of the UIViewController once you jump to another one and once you go back it's reset to it's initial state.
I have also read about the presentModalViewController with which you can push your view as a modal on top of the current controller. However you need to do this a lot and I'm a bit afraid about memory consumption issues.
What's the best way to create a multi-view application without an application view hiearchy (UINavigationController/UITabController/etc...) Typically I'd like to declare all my view controllers at the start and just switch between them as needed (when I first need a view I'll initialize it) Anyone tried something similar before?
Thanks a lot.
EDIT: Thanks for the replies, I went out and watched WwDC session about UIViewController containment and that helped me in understanding how to implement a custom UIViewController container. However there's still something I can't grasp.
When I create a custom UIViewController container I need to add children to it using addChildViewController, and that will fire the willMoveToParentController event on my child UIViewController.
Then I add the child controllers subviews into the container views using [self.view addSubview...] however this only load the views and doesn't link them to the events I have created inside my child UIViewController.
Should I use something else than addSubview? or should I use a separate UIView class to wire my events in?