开发者

How to access the instance variable of the view from its subview in iphone

开发者 https://www.devze.com 2022-12-19 22:00 出处:网络
I am new to iphone development.I want to to access the instance variable declared in uiview from its uiview subview.pl开发者_运维百科ease help me out .Thanks.Technically, you can just do [[self superv

I am new to iphone development.I want to to access the instance variable declared in uiview from its uiview subview.pl开发者_运维百科ease help me out .Thanks.


Technically, you can just do [[self superview] foo] from within one of the child's instance methods and that will give you access to the foo property on the parent (you may have to cast the superview, though). But something to consider is that in hierarchical data structures (like the UIView hierarchy), it's generally good practice for children to not "know" too many of the details of their parents, where possible.


UIView has a superview property that will point to the view's superview if it has one. You can send messages to the object it points to.


view.superview.iVar
0

精彩评论

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