2

I tried everything:

1.Using repeating NSTimers in UITrackingRunLoopMode and forcing the current GLKView's drawInRect manually. It doesn't update anything, even though the methods keep getting called;

2.Using dispatch queues with "dispatch_async", it doesn't draw my OpenGL content.

Every example i see regarding UIScrollView and OpenGL deals with the problem by changing the default runloop of the CADisplayLink, something that i'm not using with GLKViewController.

Anyone has faced this problem too?

Any insight would be awesome :)

Thanks in advance, Nuno

  • What is scrolling? The GLKViewController, GLKView or some parent element? – shein Apr 22 '12 at 16:48
  • It is the UIScrollView that is scrolling on top of the GLKView. When dragging begins, the GLKView's animated content stops. – Nuno Miguel Fonseca Apr 22 '12 at 17:46
  • I'm seeing this problem as well. @NunoMiguelFonseca any progress on a solution? I believe this issue is related to http://stackoverflow.com/questions/605027/uiscrollview-pauses-nstimer-until-scrolling-finishes but I haven't found a solution yet. – Chris May 09 '12 at 02:16

1 Answers1

2

One solution I found is to assign the view controller as the scrollview delegate and call the draw method as needed:

(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    GLKView *view = (GLKView *)self.view;
    [self glkView:view drawInRect:view.frame];
}
Chris
  • 3,577
  • 1
  • 21
  • 15
  • How did this solve your problem? In that particular example, the drawInRect method is only called at the end of the scrolling, and the same would happen to dragging, and even in "willBeginDragging" and similar. – Nuno Miguel Fonseca May 09 '12 at 19:18
  • scrollViewDidScroll is called whenever the scroll view scrolls -- it is not only called at the end of scrolling (at least in my experience). Take a quick look at the documentation for that delegate method and hopefully this solution will make more sense. Or better yet, set a breakpoint in the delegate method and see how often it gets called. – Chris May 10 '12 at 10:30
  • 1
    I had to add `[view display]` after `glkView:drawInRect:` to make this work. Make sure your drawing is pretty well optimised though, and also make sure that you are culling draw operations that are outside of the rect passed for `drawInRect:`. – damian Dec 19 '12 at 14:04
  • It works, in my case `[_glView display]`. However I have a long uicollectionview (it has uiscrollview deletegate methods too), when I scroll then tap and hold it, the render still stop. When I release, the render continue. I tried to call other uiscrollview deletegate methods still doesn't work. – Dody Rachmat Wicaksono Apr 14 '21 at 00:10