I have a UIView and try to remove it from its superview using an animation (fading to alpha 0.0). Works fine but the view is never removed from the superview although I added a delegate to AnimationWillEnd. Here's the code. The console output is not written and the view is not removed. What's wrong?
UIButton oBtn = UIButton.FromType(UIButtonType.RoundedRect);
oBtn.Frame = new RectangleF(0, 0, 100, 20);
oBtn.SetTitle("Hide", UIControlState.Normal);
oBtn.Center = new PointF(80, 120);
oBtn.TouchUpInside += delegate(object sender, EventArgs e) {
UIView.BeginAnimations(null);
UIView.AnimationWillEnd += delegate {
Console.WriteLine("Removed.");
oView.RemoveFromSuperview();
};
UIView.SetAnimationDuration(2);
UIView.SetAnimationBeginsFromCurrentState(true);
oView.Alpha = 0.0f;
UIView.CommitAnimations();
};
oView.AddSubview(oBtn);