Search code examples
objective-caddsubviewsubviewsxcode4.1

Is it correct to have subViews in the same ViewController?


So, this is my question. I have a ViewController, and I want to add 2 different Views in different position (one upper and the other lower) but they will appear at the same time, using method "addSubview", but I don't know if this is correct, to have different subViews in one Viewcontroler?
I'm not using Storyboards, I'm using XCode4.1 to iOs 4.3


Solution

  • You mix up views and view controllers.

    The number of views that a view controller can control to display its data and perform its business logic is not strictly limited.

    Nor is the number of subviews limited that a view can have.

    There is just one thing. When these views are rather independent from each other, then do not make one a subview of the other. If a is the underlying view and b and c are the indipendent subviews, then do: [a addSubView:b]; [a addSubView:c];

    Where is the problem?