title: When a subview is removed, remove from superview
body: <p>I am trying to do something very similar to <a href="https://stackoverflow.com/questions/6442236/how-to-tell-when-a-subview-is-removed-a-uiview">How to tell when a subView is removed a UIView</a></p>
  
  <p>I add a view (A) as a subview, this in turn creates a subview (B) for itself. What it want:</p>
  
  <p>When A's subview B is removed from A --> Remove A from it's superview.</p>
  
  <p>I have subclassed UIView and tried to use <code>- (void)willRemoveSubview:(UIView *)subview</code> that in turn calls a method on the superview to remove this view. But it isn't working and I think it might be because B is in the process of being removed.</p>
  
  <p>The above thread recommends using protocols, which I understand and use in my app already, but in this case I am not sure how to use it in order to do what I want and cannot find the correct reference in the Apple Dev resources.</p>
  
  <p><strong>Could you help me in using a protocol &amp; delegate to solve this problem?</strong></p>
  
  <p>Thanks</p>