UIScrollView broken and halts scrolling with OpenGL rendering (related CADisplayLink, NSRunLoop)

早过忘川 提交于 2019-12-19 03:39:17

问题


Solution note, Not a question.

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

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)

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.


回答1:


Edit: Woops, misread your post. Nevermind

As mentioned in this post, you can solve this issue by switching run loop modes. Animation in OpenGL ES view freezes when UIScrollView is dragged on iPhone




回答2:


This is also explained with a walk through in Apple's WWDC 2012, session 223: "Enhancing user experience with scroll views", second half: https://developer.apple.com/videos/wwdc/2012/.




回答3:


Here you can find a better (and more complex) solution:

Animation in OpenGL ES view freezes when UIScrollView is dragged on iPhone

that allows you to use 'NSRunLoopCommonModes' and avoids OpenGL freezing when holding a finger without scrolling.




回答4:


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

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



来源:https://stackoverflow.com/questions/4135229/uiscrollview-broken-and-halts-scrolling-with-opengl-rendering-related-cadisplay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!