UIScrollView中断并停止了使用OpenGL渲染的滚动(相关的CADisplayLink,NSRunLoop)

问题描述:

解决方案说明,不是问题.

Solution note, Not a question.

UIScrollView通过在CADisplayLink注册到NSDefaultRunLoopMode时阻止触发CADisplayLink滴答声来挂起OpenGL渲染.

UIScrollView suspends OpenGL rendering by preventing firing CADisplayLink tick when CADisplayLink registered with NSDefaultRunLoopMode.

但是,如果使用NSRunLoopCommonModes解决此问题,则UIScrollView将在突发滚动时停止滚动.并且一旦停止,它就不会再次滚动. (断)

But, if you use NSRunLoopCommonModes to solve this, UIScrollView will halt scrolling at burst scrolling. And after once halted, it does not scroll again. (broken)

并在其他线程/运行循环中注册CADisplayLink(如此问题的答案中所述:

And registering CADisplayLink in other thread/runloop (as described in answer of this question: CADisplayLink stops updating when UIScrollView scrolled) reduces UIScrollView behavior breaking, but cannot eliminate.

使用

Use UITrackingRunLoopMode. It's specifically designed for scrolling stuffs.

否则,请调用render&在-scrollViewDidScroll处也显示代码,不仅在CADisplayLink的tick回调中.

Otherwise, call render & present code at -scrollViewDidScroll too, not only in CADisplayLink's tick callback.