Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView Animations with Objective-C Blocks

I have been playing around with the two different ways of doing UIView animations: begin/commit and Blocks.

I have noticed that the beginAnimations:context: / commitAnimations way of doing things is nicely asynchronous, keeping the UI free while the animation is running.

However, I also noticed that the animateWithDuration:animations:completion way seems to block the UI, making it unresponsive while the animation is running.

I thought one of the main points of using blocks was to achieve asynchronous execution easily. Why does the blocks variant of the UIView animarions block the UI while the begin/commit variant does not?

Edit:

My question originally assumed that the blocks animation was a synchronous operation and blocked the UI. As it transpired from Jeff Kelly's answer, that this isn't the case. My original assumption was incorrect, the blocks animation is not synchronous. See Jeff's answer for the details.

like image 206
Jasarien Avatar asked Feb 22 '11 14:02

Jasarien


1 Answers

Are you using the right UIView class method? If you use +animateWithDuration:delay:options:animations:completion:, you can specify a bitmask of options. One of the possible options is UIViewAnimationOptionAllowUserInteraction, which sounds like just what you want.

like image 166
Jeff Kelley Avatar answered Sep 28 '22 01:09

Jeff Kelley