0
我是iPhone新手,我试图在UIView和另一个包含常规UIView和UIScrollView的UIView之间做翻转动画,依次滚动视图有几个UIViews作为子视图。在UIView和UIScrollView之间做翻转动画的问题
在动画开始之前,滚动视图需要偏移到特定的点以显示特定的子视图(用户跳转到滚动视图中的特定“章节”)。
它动画很好,但问题在于它会'有时'(可能每隔三次)使用滚动视图的子视图之一启动动画,而不是使用原始UIView启动动画('overlayView'在下面的代码中)。我怀疑这与在动画之前设置滚动视图的偏移量有关。
这是我目前要做的事:
// get the MPMoviePlayer window that has the views to animate between as subviews
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
// tell the controller of the scroll view to set the scroll view offset
[instructionControlsController setInstructionImageWithNumber:[self chapterAtTime:currentTime]];
// Animate transition to instruction view
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView: moviePlayerWindow cache:NO];
// the views to animate between
[moviePlayerWindow sendSubviewToBack: overlayView];
[moviePlayerWindow bringSubviewToFront: instructionControlsController.view];
[UIView commitAnimations];
控制器中setInstructionImageWithNumber方法是这样的:
- (void) setInstructionImageWithNumber:(int)number
{
if (number < kNumberOfPages)
[scrollView setContentOffset: CGPointMake((number * kImageWidth), 0) animated:NO];
}
什么,我可能是做错了任何想法,为什么我得到这个行为动画有时看起来很好,有时甚至没有?
这样做的伎俩,谢谢!我会再看一下performSelector - 看起来他们在将来也可以非常方便。 – Cactuar
原来我很快就说过了,这个错误仍然存在 - 但现在似乎更少出现,而且它在模拟器中从未发生过。我会继续调查... – Cactuar
因为它在模拟器中从来没有发生过,所以我不知道该设备是否需要更多时间来准备(或清理)所有东西。如果你改变afterDelay会发生什么:从0.0到0.1甚至更高? – Rob