I am experiencing an issue with activity indicator freezing when I move application to background and then bring it back to foreground. The application can be loading some data over the network when it is moved to background. Hence I display an activity indicator to the user. I have added the code to make sure that the task finishes in the background. When the application is brought to foreground immediately and the data is not completely loaded, the spinner stays on the screen but it stops spinning. When the data is completely loaded, the spinner disappears.
Any idea why the activity indicator freezes and what could be a possible solution to it.
Thanks.
There's almost no reason for an app in the background to be updating its UI.
For one, who is there to see it? Another reason that the indicator freezes is that going to the background stops UI updates and animations that needlessly drain the device's battery and slow down the foreground app.
From Apple's excellent iPhone Application Programming Guide, the app delegate method
-applicationWillEnterForeground:
is called whenever the application comes into foreground.You can override this method and add logic to wake up widgets here. Or you subscribe your class (view controller, etc.) to listen for the
UIApplicationWillEnterForegroundNotification
notification. If you listen for this notification, you could call a selector that updates the state of the UI, given whatever the application is doing at the time.