Resume Animation

Discussion in 'iOS Programming' started by nickculbertson, Mar 21, 2011.

  1. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #1
    I have a View based application where I switch views with presentModalViewController. On my RootView I have an animation loop triggered by an NSTimer that plays continuously in the background while I'm viewing my SecondView. My question is, how can I stop the animation in RootView from running when I've selected the SecondViewController? I would like to resume the animation when I return to the RootView. Should I invalidate the NSTimer then create it again?

    Thanks,
    Nick
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Instead of invalidating the timer, have you considered setting a flag and then checking the flag within the selector method to decide whether to animate or not? I guess an approach like this would be okay as long as the timer is not firing very frequently. If it is, the overhead of it firing might need to be considered when keeping it running.
     
  3. nickculbertson thread starter macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #3
    Thanks Dejo.

    Yeah, it is firing every .02 seconds. The animation is of four menu buttons moving like in this VIDEO at 0:32. The animation working in the background is eating up the memory for the rest of my app. I'll do some more research on the subject but if you think of any other suggestions shoot 'em my way.
     

Share This Page