ViewWithTag and getting views deep inside the hierarchy

if i have the following view hierarchy

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

how to get UILabel with tag 1 from link from top level view?

+2


a source to share


1 answer


As per the documentation, viewWithTag: returns "the view in the recipient hierarchy that matches the tag". This means that he is looking for the entire hierarchy, and not just children at once. So, assuming the UILabel you are looking for is the only view with tag = 1, you should simply do



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

      

+7


a source







All Articles