开发者

How can I iterate thru all controls from a View on iOS?

I want to iterate thru all controls existing in a View on iOS when the view is loaded.

Also, it would be acceptable to have a callback that is called when these contr开发者_运维技巧ols are initialized.

How can I obtain this?


To iterate through subviews (controls) in a parent view, call the parent view's -subviews method:

for (UIView *subview in [parentView subviews]) {
    /* do something with subview */
}

You could subclass the control, creating a custom control. Here, you override the custom control view's initializer method. In this method, you would call the parent's initializer, and add your custom code.


for (UIView *aView in [myView subviews]) { //do something with aView }?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜