Sequential Animations

Member
Posts: 27
Joined: 2012.05
Post: #1
Hello,

I have an array of UIButtons, which I want to animate onto the screen one by one.

When I loop through the array and call the animation function, which simply transforms and changes the center position of the button, all the buttons get animated together.

I want the animation to run for one button at a time, and then go on to the next button in the array.

Does anyone know why this is happening, or what the solution to this problem could be?

Thanks,
avidgamer101
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2012.12
Post: #2
Possibly stating the obvious, but you are including a delay each time you invoke an animation aren't you? Could your buttons message a controller once they are in position (i.e. the animation has finished), and the controller then can fire off the next animation?
Quote this message in a reply
Member
Posts: 27
Joined: 2012.05
Post: #3
I am setting a delay to be the same amount of the time as the animation. Intuitively, this would finish the first one before starting off the second.

However, i am in a for loop, so I think the compiler is going through the loop, putting the executable animations into a single thread and executing it.

I have tried looping the animations through a completion block, but that is no good as well.

Any suggestions??
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2012.12
Post: #4
In that case, in the for loop, make the delay the cumulative sum of the previous delays. If the first delay is 0.5s, the second should 1s, the third 1.5s, etc.

The loop will be executed so quickly that the animations will all appear to happen at the same time.
Quote this message in a reply
Member
Posts: 27
Joined: 2012.05
Post: #5
that is working!

thanks a ton!!
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2012.12
Post: #6
Great!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Slightly more complex animations through UIView Animations avidgamer101 8 5,548 Feb 12, 2013 10:39 AM
Last Post: SethWillits