简体   繁体   中英

UIScrollview setContentOffset immediate animation?

Is there anyway to get the setContentOffset animation to happen immediately instead of waiting until the app returns to the main run loop? I tried setting the animation property to NO and nesting inside of an animation block but it still waits until returning to the main run loop. I've also tried using a sub method to perform the animation. My problem is I perform some heavy work after setting the contentOffset so the scroll view waits until this work is complete to animate the setting of the content offset so it appears to lag for a second.

I moved the heavy work to scrollViewDidEndAnimation and it resolved my issue. The timer didn't work because my heavy work relies on the content offset position after the scrolling animation is finished and using the timer couldn't assure an accurate offset.

No drawing will happen until the run loop gets time. If your heavy work does not need to be on the main thread then kick off another thread, otherwise schedule a timer with a time interval of 0 to perform the heavy work after the scroll view draws.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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