简体   繁体   English

ios动画从延迟开始

[英]ios animation start with delay

just wanted to clear one thing, in iOS animations start in thread but before starting it, does it waits for main UI thread to be finish.Once animation started then u can do anything in main thread at same time. 只是想清除一件事,在iOS中动画从线程开始,但是在开始之前,它是否等待主UI线程完成。一旦动画开始,您就可以同时在主线程中执行任何操作。

[UIView transitionFromView:currentVisible
                                toView:reuseablView
                              duration:0.6
                               options:(UIViewAnimationOptionTransitionCurlUp|UIViewAnimationOptionShowHideTransitionViews)            
                            completion:^(BOOL finished) {
                                }
                            }];

[self callFunction1];

Here, animation starts with very little delay I think it waits for functioin1 call. 在这里,动画开始时几乎没有延迟,我认为它等待functioin1调用。

Any,Idea? 任何想法?

When you call [self callFunction1] , you're blocking the main thread so any animation is going to stop (or in this instance, not start yet). 调用[self callFunction1] ,您正在阻塞主线程,因此任何动画都将停止(或在这种情况下尚未开始)。 If it's a long running method you should move it to another thread. 如果是长期运行的方法,则应将其移至另一个线程。

The animation should be started on the main thread although it actually gets executed on a higher thread than what your app accesses so it can still perform while blocking because of how the core animation rendering server works. 动画应该在主线程上启动,尽管实际上它是在比您的应用访问的线程更高的线程上执行的,因此由于核心动画渲染服务器的工作原理,动画仍可以在阻塞时执行。 Make sure you at not calling this from some network code while. 确保您暂时不会从某些网络代码中调用此代码。 It on the main thread. 它在主线程上。 If the second method is blocking the animation probably will proceed but the app and touch events would not work while being blocked. 如果第二种方法被阻止,则动画可能会继续进行,但是在被阻止时,应用程序和触摸事件将无法正常工作。 If the second method blocks long enough the delay on the animation could cause it not to fire on time. 如果第二种方法阻塞的时间足够长,则动画上的延迟可能导致其无法按时触发。 But once started the animation should be good to go even with the next method blocking. 但是一旦开始动画,即使下一个方法阻塞也应该很好。 I recommend you don't block the main thread though. 我建议您不要阻塞主线程。 If you want that method to be called after the animation it should be in the completion block. 如果要在动画之后调用该方法,则该方法应该在完成块中。

Finally to prove this you can call the animation first and then call sleep. 最后要证明这一点,您可以先调用动画,然后再调用sleep。 Your app would be unresponsive but the animation would continue. 您的应用将无响应,但动画将继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM