views:

61

answers:

2

Here's a hypothetical question:

Say I subclass a UIView that draws a triangle and I want this triangle uiview to part of the screen. And then say I subclass another UIView that draws a rectangle and I want the rectangle to take part of the screen.

In other words:

1) Can a view-controller have multiple views simultaneously being drawn on the screen
2) If so, can I set location bounds for these views. Say I want a view 50x50 on the left side of the screen etc? 3) Can I specify the bounds via interface builder?

Thanks!

+3  A: 

A view controller owns a view hierarchy, not just a single view. However, that hierarchy must have a root at some top level view, which ends up being self.view for the view controller.

The view that is self.view need not have any direct content to display. It can simply be a UIView that holds other views, your rectangle and circle. The root view should be large enough to cover (really be under) any other views it contains. All the views in the hierarchy may be laid out in interface builder.

drawnonward
A: 
  1. yes
  2. yes
  3. yes
ohho