I have a UIView class which I am currently removing from my view by using from inside the class [self removeFromSuperview]
. Hopefully that's the correct thing to do.
However, now from my view controller (of which I add this view to) I need to know when it has removed itself so that I can call a method when this happens.
Generally speaking, the view shouldn't be doing things like removing itself. That's the job of the view controller.
If a UIView
subclass can produce events that require the view hierarchy to be changed, I would define a delegate
property for that view, and when an event occurs, call a method on that delegate. Then, when your view controller adds the view, it would set itself as the delegate and define the relevant method to handle the event.