I’m looking for a way – how to detect: my UIView was added as subview to some other view to adapt it’s frame to superview.
F.e I should put my UIView to the bottom of parent view (but I don’t know which parent will be… 😐 )
The only way that I can see is override parent addSubview method, but I don’t have access to it.
I would like to have delegate method like:
- (void)viewDidAddedAsSubview:(UIView)parentView
or smth like that
Maybe, somebody knows how to do this.
Thanks a lot
If the view you are adding is a custom
UIViewclass, then override thewillMoveToSuperview:or thedidMoveToSuperViewmethod. Take into account that these are called when the view is removed as well.If the view you are adding is not custom
UIViewthen you can add an observer on the view’ssuperviewproperty.