I have a rather annoying problem. I have a table view with blog entries (collected from a RSS feed). When the view loads, I apply a loading screen to the blogViews view via -addSubview:. And in -viewDidAppear: I start to load the data. This works and all with the iOS 5 simulator and on my iPhone 4 with iOS 5.0.1.
But when I do it on the 4.3 simulator, the loading screen doesn’t appear. The screen is locked on the previous screen (another tableView) until the load is finished.
The problem is, of course, the loading shouldn’t start until the view has appeared. To exemplify: When I click the tab bar button to open the blog, the load starts (which is in -vievDidAppear:), and when the load is finished, the screen appears – it should be the other way around! This is weird, why does it do it like that on 4.3 and not 5?
Should I use -viewWillUnload method in the first table View and apply a loading Screen? That means that there will always be a loading screen (for a flash of a second) when I unload it when there is no need of a loading screen.
(By loading screen I mean an UIImageView initiated with an image, and an activityIndicator on top)
Thanks for any input!
As Mark points out, your problem is related to blocking the main thread while performing a long operation that should in fact be performed on the background.
If you do so, it shouldn’t matter when viewDidAppear: is called, since you won’t be blocking the main thread while performing the loading.
You could solve this performing your loading operation on the background and then going back to the main thread to remove the loading indicator. You can do it easily with GCD: