IOS: UIScrollView and OpenGL

So, I have an OpenGL view (glView) that displays the menu I want to scroll through. I tried to avoid reusing UIScrollView, and therefore I have a scroll over glView.

The problem is that scrollview scroll pauses rendering

A similar issue was discussed here. Animation in OpenGL ES view freezes when UIScrollView is dragged onto iPhone.

The problem is that I have no idea that [displayLink addToRunLoop: [NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes]; refers to

I created a new CADisplayLink and tried to do it with no luck

I tried calling the render method in scrollViewDidScroll

I tried to call [self.view setNeedsDisplay];

I also found a link to call timerLoop?

Can someone help me please

+4
source share
2 answers

So I found a solution :)

create CADisplayLink * _displayLink; property (you need to import QuartzCore)

You have a scroll up.

#pragma mark - scrollView Delegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //code for moving the object here } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [self startDisplayLinkIfNeeded]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { if (!decelerate) { [self stopDisplayLink]; } } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self stopDisplayLink]; } #pragma mark Display Link - (void)startDisplayLinkIfNeeded { if (!_displayLink) { // do not change the method it calls as its part of the GLKView _displayLink = [CADisplayLink displayLinkWithTarget:self.view selector:@selector(display)]; [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:UITrackingRunLoopMode]; } } - (void)stopDisplayLink { [_displayLink invalidate]; _displayLink = nil; } 
+3
source

Please refer to Apple WWDC 2012 Session 223 . Starting at 9:21 p.m., they talk about integrating UIScrollView with the OpenGL view. The interesting part starts at 25:53.

The main source code was written by Burf2000, but this video explains WHY it works, how UIScrollView works, and how it can interact with OpenGL. It also helped me debug my code.

+1
source

All Articles