开发者

Does Cocoa Touch have a UIView or component equivalent to Adobe Flex's HBox or VBox?

Is there any type of container, view, class or framework, in objective-c, whereby one can add UI elements to the view and have them automatically align either vertically or horizontally? Or is thei开发者_高级运维r a way to get UIView to have this behavior?

What I am trying to accomplish is to dynamically and conditionally add UI elements to a form but not have to worry too much about the layout, as I am not using Interface Builder for this part.

I've done quite a bit of coding with flex/actionscript and found their HBox and VBox components to be pretty handy for this.

Does anyone know how to handle auto layout this way or in a similar fashion?


There is no direct equivalent that I am aware of. In Cocoa each view can be a container of many subviews. The way you control the layout of your subviews can include:

  • Using the autoresize mask of each subview to have the subviews "do the right thing" as the container view is sized/resized, and
  • Implement your own container rules by subclassing UIView and implementing the layoutSubviews method. This will allow you to implement any simple alignment rules you desire.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜