开发者

Cocoa-Touch: Can I have multiple views per view-controller, or specify bounds of a uiview?

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-control开发者_如何学JAVAler 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?


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.


  1. yes
  2. yes
  3. yes
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜