使用 UIViewAnimationTransitionFlip 实现闪烁动画
我有一个带有 2 个子视图的容器视图。我想从一个翻转到另一个。问题是出现某种闪烁。它不会发生在 iPhone 3GS 上,但会发生在模拟器和 iPhone 3G 上: http://www.hanspinkaers.com/upload/Flickering.png
有谁知道为什么会发生这种情况?
这是代码:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.75];
[UIView setAnimationDidStopSelector:@selector(afterAnimationProceed)];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containerView cache:YES];
if(self.mapViewController.view.superview){
[self.mapViewController.view removeFromSuperview];
[self.containerView addSubview:self.tableController.view];
} else {
[self.tableController.view removeFromSuperview];
[self.containerView addSubview:self.mapViewController.view];
}
[UIView commitAnimations];
提前致谢!
汉斯
I have a containerview with 2 subviews. I want to flip from one to another. The problem is that some kind of flickering appears. It doesn't happen on the iPhone 3GS, but on the Simulator and the iPhone 3G:
http://www.hanspinckaers.com/upload/Flickering.png
Does anyone know why this happens?
This is the code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.75];
[UIView setAnimationDidStopSelector:@selector(afterAnimationProceed)];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containerView cache:YES];
if(self.mapViewController.view.superview){
[self.mapViewController.view removeFromSuperview];
[self.containerView addSubview:self.tableController.view];
} else {
[self.tableController.view removeFromSuperview];
[self.containerView addSubview:self.mapViewController.view];
}
[UIView commitAnimations];
Thanks in advance!
Hans
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅供参考,当您有 2 个以上单独的动画工作时,通常会发生闪烁,请尝试将它们全部放入单个动画块中并提交组动画。
fyi flickering usually happens when you have 2+ seperate caanimations working, try to put them all into a single animation block and commit the groups animations.
我无法重现您的问题,但如果转换开始时表格视图或地图视图正在滚动,我确实会遇到问题。
也许在进行转换之前禁用用户交互并停止任何滚动等会有帮助?
除此之外,抱歉!
山姆
I can't reproduce your problem but I do get issues if the tableview or mapview is scrolling when the transition starts.
Perhaps disabling user interaction and stopping any scrolling etc just before doing the transition will help?
Apart from that, sorry!
Sam