Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone lost all UI transition animation

Currently I encounter an issue somehow, the application lost all those artistic UI animation for example, page flipping, alert view popup, action sheet slide up and etc. That means all those UI will show up immediately without any transition animation. It looked very weird.

Firstly, the app will run smoothly until something trigger the issue above, and after that only re-run the app or kill the app will stop the problem.

There is no error message or any clue that I can figure out what could be the reason. Have any one of you guy has encountered similar issue as above? Please share with me how am I able to solve the issue above. Thanks.

like image 457
Sam YC Avatar asked Jun 11 '13 03:06

Sam YC


1 Answers

Animations may get disabled for the entire app whenever an attempt is made to animate views on a background thread, e.g. by calling one of UIView's animateWithDuration:animations: family of class methods from a background thread. Be sure to update your app's UI only from the main thread.

You can check if code is running on the main thread by testing [NSThread currentThread].isMainThread and you can ensure it runs on the main thread like so:

dispatch_async(dispatch_get_main_queue(), ^(void) {
    // Your code
});

Alternatively, ensure that you're not calling [UIView setAnimationsEnabled:NO] anywhere, as that will also disable animations for the entire app.

like image 133
johnpatrickmorgan Avatar answered Sep 17 '22 14:09

johnpatrickmorgan