if I have the following view hierarchy
UIView --- top level view
--UIButton --UIView ----UILabel ----UILabel -- tag = 1ho开发者_如何学Gow do I get UILabel with tag 1 from a reference from the top level view?
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];
精彩评论