开发者

viewWithTag and retrieving views deep within the hierarchy

if I have the following view hierarchy

UIView --- top level view

--UIButton

--UIView

----UILabel

----UILabel -- tag = 1

ho开发者_如何学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];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜