Using a progressView and refreshing the screen
When my app loads for the first time it updates a SQLite table which takes about a minute. To keep the user informed I planned to use a progressView to show the data loading but while the process is running the screen just stays black until the process has finished. The process is called from the viewDi开发者_如何学GodLoad so do I need to use some sort of thread to enable the screen to finish loading in the background?
You can start animating the progress view when the background processing is being done and then stop animating and hide once you have the data to load on the screen.
You do not need to use any threads for the above, but for background processing you can spawn a thread and then post notification on the main thread once you have data to be drawn on the screen as UI updates need to be handled in the main thread only.
performSelectorOnMainThread can be used to post event to the main thread.
If you're doing the loading on the main thread then your screen won't update because UI components are run on the main thread.
So, to show a progress bar you need to move the sqlite updating to a new thread, yes. :)
See http://www.xprogress.com/post-36-threading-tutorial-using-nsthread-in-iphone-sdk-objective-c/
精彩评论