Friday, April 15, 2011

Multiple View Controllers, am I screwed ?

When I first started this iPhone app, I was still a beginner so I was taking code from samples.

I have 4 Views (UIView) with 4 View Controllers (UiViewContorllers). They all sit on the same level in Interface Builder.

UiViewA is the main Menu, and it has buttons that when pressed loads ViewB,C,D via addSubView:ViewB(c/d/etc) . I am running into a problem now that only ViewA's ViewController is getting all the messages and notifications.

Am I screwed here? Should I have NOT been adding subviews of ViewB,C,D directly from ViewA? Should I have been loading the ViewController instead?

What work around do I have ?

So far, I have been transforming the other views directly if I wanted rotation.

Any help appreciated

From stackoverflow
  • You're on the right track: loading the UIViewController instead of the UIView should solve this for you. You can accomplish this as follows (from your first UIViewController):

    [self presentModalViewController:anotherViewController animated:YES];
    

    This will slide another UIViewController up over your current view and preserve its lifecycle and logic. Hope this helps!

0 comments:

Post a Comment