tags:

views:

92

answers:

1

if i have the following view heirarchy

UIView --- top level view
--UIButton
--UIView
----UILabel
----UILabel -- tag = 1

how do I get UILabel with tag 1 from a reference from the top level view?

+2  A: 

According to documentation, viewWithTag: returns “the view in the receiver’s hierarchy that matches tag.” This means it searches the whole hierarchy, not just immediate children. So, assuming that the UILabel you are looking for is the only view that has tag=1, you should be able to simply do

UILabel *someLabel = (UILabel *)[topLevelView viewWithTag:1];
Jaanus