开发者

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

开发者 https://www.devze.com 2023-03-09 17:57 出处:网络
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 initialize

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

精彩评论

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