I try to remove a view from it's superview after being animated offscreen. But it seems when I add the removeFromSuperview
call after when the animation is supposed to end, the view would no animate at all but instead disappear instantly from the screen.
So why is there no animation when I add the [[self pickerView] removeFromSuperview];
to the method below ?
- (void) slidePickerOutView
{
[UIView beginAnimations:@"slidePickerOutView" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDidStopSelector:@selector(slidePickerOutViewEnded:finished:context:)];
CGRect r = CGRectMake(0, 480, 320, 244);
[[self pickerView] setFrame:r];
[UIView commitAnimations];
}
- (void) slidePickerOutViewEnded:(NSString *)id finished:(BOOL) finished context:(void *) context
{
//Stop observing the 'Done' button
[[self pickerView] removeObserver:self forKeyPath:@"valueSelectDone"];
[[self pickerView] removeObserver:self forKeyPath:@"selectedValue"];
[[self pickerView] removeFromSuperview];
[self setPickerView:nil];
}