views:

153

answers:

2

Can a UIViewcontroller contain more than one UIView?

+2  A: 

Yes, many.

Each button, or text field or image, or ... is a view. A view controller can handle many many views. Of course, there is one view that is the parent of all others, and the view controller keeps track of that one and can then follow the tree down to handle the children (for the purposes of handling touch, or updating, etc.).

mahboudz
I'd emphasize the fact that the view controller only **has** one view: its own. However, that view can *contain* many others as subviews, and the controller can *manage* all of them (via outlets, etc.).
jtbandes
+1  A: 

For clarity, NO. A UIViewController has one UIView. That UIView, like all UIViews, can contain subviews. If you want to control two views, create instance variables for each of them and add them both to your UIViewController's view variable.

David Kanarek