animationControllerFor presentedController和animateTransition之间的自定义过渡动画未知的延迟 [英] Custom transition animation unknown delay between animationControllerForPresentedController and animateTransition
问题描述
我的目标是使流畅的动画在第二视图控制器的第一个视图控制器和年底开始。
My aim is to make smooth animation started in the first view controller and end in the second view controller.
,我与过渡动画采用符合<$ C C> UIViewControllerAnimatedTransitioning $ C $ç>和<$ C C> UIViewControllerTransitioningDelegate $ C C>的协议对象的实验。
我设立在故事板两种查看控制器(VC),并将其与赛格瑞(默认显示)连接。我在第二VC也取得了开卷SEGUE方法的第一个VC并设置一个按钮吧。
I'm experimenting with transition animation using object that conform to UIViewControllerAnimatedTransitioning
and UIViewControllerTransitioningDelegate
protocols.
I set up two view controllers (VC) in the storyboard and connect them with segue (default show). I also made unwind segue method in the first VC and set up a button for it in the second VC.
我有奇怪的问题。
我的目标有方法
I have strange problem. My object have methods
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
self.presenting = true
NSLog("start")
return self
}
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
if presenting {
NSLog("Animation Push")
transitionPush(transitionContext)
}
else {
NSLog("Animation Pop")
transitionPop(transitionContext)
}
}
我从第一个VC动画两种不同的方法来第二次和第二次从第一VC。
当我启动我赛格瑞有 animateTransition
方法之间很奇怪延迟animationControllerFor presentedController
和。有时也可以是1秒左右,而我的整个过渡动画必须为1秒加这个意外的延迟过大。
这里是一个日志:
I have two different methods for animation from first VC to second and from second to first VC.
When I activate segue I have very strange delay between animationControllerForPresentedController
and animateTransition
methods. Sometimes it can be about 1 second, and my whole transition animation must be 1 second plus this unexpected delay is too big.
Here is a log:
2015-02-08 19:52:33.528 MyApp[1318:119598] start
2015-02-08 19:52:33.979 MyApp[1318:119598] Animation Push
我不知道为什么这种延迟会发生,如果有一种方法来消除或减少呢?我想,以检查是否这可能是我的code,但我没有找到任何证明这一点。随意问的更多信息。
I don't know why this delay occur and if there a way to remove or reduce it? I tried to check if this could be my code, but I didn't find any prove of it. Feel free to ask for more info.
推荐答案
我有同样的问题。你可能不从主线程(presentViewController调用)触发动画。
I had the same problem. You're probably not triggering the animation from the main thread (presentViewController call).
这解决了这个问题,我(的Objective-C code):
This solved the issue for me (Objective-C code) :
dispatch_async(dispatch_get_main_queue(),
^{
[self presentViewController:viewControllerToPresent
animated:YES
completion:nil];
});
这篇关于animationControllerFor presentedController和animateTransition之间的自定义过渡动画未知的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!