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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com