NSOperation for animation loop causes strange scrolling behaviour

Posted by Tricky on Stack Overflow See other posts from Stack Overflow or by Tricky
Published on 2010-03-27T16:09:20Z Indexed on 2010/03/27 16:13 UTC
Read the original article Hit count: 318

Hi,

I've created an animation loop which I run as an operation in order to keep the rest of my interface responsive. Whilst almost there, there is still one remaining issue. My UIScrollViews don't seem to be reliably picking up when a user touch ends. What this means is, for example, if a user drags down on a scroll view, when they lift their fingers the scrollview doesn't bounce back into place and the scrollbar remains visible. As if the finger hasn't left the screen. It takes another tap on the scrollview for it to snap to its correct position and the scrollbar to fade away...

Here's the loop I created in a subclassed NSOperation:

  • (void)main { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSRunLoop *runLoop = [NSRunLoop currentRunLoop];

    _displayLink = [[CADisplayLink displayLinkWithTarget: self selector: @selector(animationLoop:)] retain]; [_displayLink setFrameInterval: 1.0f]; [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes];

    while (![self isCancelled]) { NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init]; [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; [loopPool drain]; }

    [_displayLink invalidate];

    [pool release]; }

DOes anyone have any idea what might be going on here, and even better how to fix it...

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk