Re: Observing frame change of a subview
Re: Observing frame change of a subview
- Subject: Re: Observing frame change of a subview
- From: Kyle Sluder <email@hidden>
- Date: Sun, 15 Apr 2012 13:06:28 -0700
On Apr 15, 2012, at 12:42 PM, Luc Van Bogaert wrote:
> Hi,
>
> I have this custom view, that can have any number of subviews. The custom view should redraw itself whenever any of the subviews frame changes. I'm trying to find a way to do this.
>
> I'm thinking of adding the custom view to the default notification center as observer for any frame change notifications. When such a notification comes in, I would call a method in which the view could check if the sender of the notification is indeed a subview and then act accordingly.
>
> I suppose this would work, but I'm wondering if there is a more efficient way of doing this.
> Any advice would be appreciated.
Any subview, or any descendant view?
If it's just direct subviews, you can add the observer in your superview's -didAddSubview: rather than subscribing for all frame change notifications (of which there will be a _lot_) and filtering out the ones for your descendants.
Can I ask what specifically you're trying to accomplish? Maybe the better approach is to push the frames down to your subviews rather than reacting to their resizing.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden