title: Remove UIView from super view after animation ended
body: <p>I am animating a UIView (alpha) property and I want that after the animation has finished I can remove it from the super view. </p>
  
  <pre><code>    -(void) hideOverlayView
  {
      [UIView beginAnimations:nil context:nil];
      [UIView setAnimationDuration:1.0];
  
      [topView setAlpha:0];
  
      [UIView commitAnimations];
  
  }
  </code></pre>
  
  <p>One option is to use performSelector with delay option but is there a more compact way?</p>
  
  <p>UPDATE 1: </p>
  
  <p>Why does this code remove the view instantly? </p>
  
  <pre><code>[UIView beginAnimations:nil context:nil];
      [UIView setAnimationDuration:1.0];
      [UIView setAnimationDelegate:topView];
      [UIView setAnimationDidStopSelector:@selector(removeFromSuperview)];
  
      [topView setAlpha:0];
  
      [UIView commitAnimations];
  </code></pre>
  
  <p>I should mention that first I am doing a fade-in animation and then fade-out. Above is the fade-out code which removes the UIView instantly instead of having the fade-out effect.</p>