Wednesday 2 September 2009

Accessing Views Created in Interface Builder

There is an easy way to access views created with Interface Builder in the view hierarchy.

In Interface Builder, set a value for the "Tag" property of the subview (first pane of the info window) you are interested in.

Then, you can programmatically access the subview of a view with tag value n with the following command:

UIView * subview = [view viewWithTag: n];
This technique is very useful if you want to manipulate views created with Interface Builder at runtime.