What might cause an App to stop responding correctly to interface events? One problem that I’m facing is that my app stops doing all kinds of animations, for instance, the keyboard doesn’t animate, it just appears in the screen. The rotation of the device is not animated, it just rotates without animation. UIAlertView shows and dismisses without animation.
I’m developing a high performance app that creates and deallocs several objects per sec. I try to use as little memory as possible. This problem I’m describing is not preceded a by memory warning and I’m not catching any exceptions (I log all of them).
If anyone can give me any advice, I’d really appreciate it.
Obs.: There is another thing i’m curious: in my app, when i have this problem, the uiview animations stop happening. But CALayer animations are executed normally. Is there a explanation for that?
It sounds as if you’re doing some operation that is blocking the main thread. All UI is done on the main thread, so if you’re also doing some long calculation on there, this will cause the UI to stop responding. Are you doing synchronous url requests? Again, this will block the main thread.
You should move as much non-UI code to a background thread as possible… do this using either GCD or
NSOperationsTake a look at Apple’s Concurrency Programming Guide.
Apple’s take on NSThreads…
*…moving away from threads may not be possible in all cases, performance (and the simplicity of your code) can improve dramatically in places where you do make the switch. Specifically, using dispatch queues and operation queues instead of threads has several advantages:
Also, see this question on NSThread vs NSOperationQueue.