在我的 iPhone 应用程序中,有一个窗口出现在主窗口之上。这是我的关闭按钮的代码;
-(IBAction)cancel{
[UIView beginAnimations:@"Animation" context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[self.view removeFromSuperview];
//[_window addSubview:view2];
[UIView commitAnimations];}
窗口正确关闭但动画不会执行。我不明白为什么。
谢谢
最佳答案
我认为这是因为您在动画期间从 super View 中删除了 View 。动画不会发生,因为 View 消失了。您应该等到动画完成后才能移除以查看,这可以通过设置委托(delegate)和选择器来实现,在动画完成时调用。
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
然后在
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[self.view removeFromSuperview];
}
关于iphone - 关闭动画不会运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577558/