title: Perform a task (in iOS) after animation has finished
body: <p>So I have this line of code:</p>
  
  <p><code>[tableView setContentOffset:point animated:YES];</code></p>
  
  <p>and I want to run another piece of code after the animation ends. My attempt was to throw the animating code (setContentOffset) in a separate method and calling it using:</p>
  
  <p><code>[self performSelectorOnMainThread:@selector(scrollMethod:) withObject:sender waitUntilDone:YES];</code></p>
  
  <p>The problem is that the method returns immediately, not after the animation is finished, even though waitUntilDone is YES, but apparently that is how animation works.</p>
  
  <p>I know that I can use thread waiting but it is not clean, so I will only use it as a last resort. (Maybe I would use this if I know the time it takes the scrolling animation to happen.)</p>
  
  <p>Any ideas on how to go about this are welcome.</p>
  
  <p>(P.S. The scenario is this: I am showing a popover, which is displayed perfectly when there is no keyboard, however, if the keyboard is visible, the popover's height shrinks which sometimes reduces it to almost border only. So just before showing the popover, I want to scroll the view upwards so that the popover never pops in the keyboard.)</p>