UIScrollView Pauses Active Timers?

Discussion in 'iOS Programming' started by Darkroom, Feb 9, 2010.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    i'm building a sound engine entirely based on OpenAL for portability. there are lots of controls and settings within my example UI so i've place everything in a scrollView. i've noticed that during any of my sound animations (panning, vibrato, etc.), which rely heavily on repetitive timers, the timers stall if i begin scrolling. scrolling kills my sound animations. to be clear, scrolling only seems to pause my timers, which will continue from where they were paused when scrolling stops.

    i'm not planning on using a UIScrollView in a published app, but i still find this to be a bit on the ridiculous side of things. :rolleyes:

    any thoughts? workarounds?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    The UIScrollView will be pausing the main run loop as it processes the UI interaction (it may well be starting it's own run loop for that). This will cause your timers to "stall" as they are also fired off the main run loop.

    Possible solution: create your own run loop running on a separate thread and schedule the timers on that run loop.
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    You need to add your timers to the runloop using NSRunLoopCommonModes. Then they won't be paused during scrolling.
     
  4. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #4
    oh right! i never though about the main run loop. thanks. and using NSRunLoopCommonModes works perfectly.
     

Share This Page