2
votes

I've got a stupid UI Problem right now with one of our apps.

I start with a UINavigationController which is the Initial View Controller in my Storyboard. The Root view controller is a UIViewController witch a UIScrollView as subview. The UIScrollView itself has paging enabled and contains several UIViewControllers.

Now here is my problem: The UIViewControllers (lets call them View #1) in the UIScrollView should react to a button event and make a segue to another UIViewController (View #2) which needs to get data from the previous UIViewController and needs to send data back by delegate methods.

When I try to get the UINavigationController and push View #2 on it, nothing happens. Showing it via presentViewController of course works.

Diagramm

Could you just help me a little bit, tell me that this doesn't work and when not why? I'm a little bit stuck at this point and i don't know how to proceed.

1
+1 for the good process figure :)Kjuly
thanks...just wanted to make the scenario clear :)chritaso

1 Answers

2
votes

DO NOT put UIViewControllers inside another UIViewController (atleast pre iOs5) that goes against apples development guidelines .. The UIViewControllers life cycle is managed internally and if you directly add the UIViewController as a subview a lot of methods such as

viewDidLoad
viewWillAppear
viewDidAppear
. . .

will not be called and from my experience will lead to really erratic behavior

Try and use custom UIView objects to get your internal logic for each view agreed this somewhat breaks the MVC pattern but this would be the best way to go about your issue

But iOS 5.0 added containment UIViewControllers that correctly handles those lifecycle events by adding child view controllers. so if you are targeting only post iOs 5 devices this maybe a good way to about it

Have a look at this and this