im working with core-data for the first time, and my app is handling a lot of data (1000+ managedobjects at least), so it takes a while to load certain views.
example: i have a view that basically holds a tableview that contains information about specific core-data entities. the view will hold between 10 and 100+ items (grouped), and i have loading times to a couple of seconds. basically that is not really a problem, but i suspect users to get irritated when a view is loading without any information until it shows.
i load my data in the ‘viewWillAppear’ because it has to be reloaded every time due to change.
question: how can i display a loading screen (progress indicator) while the view loads? it does not have to be fancy, just maybe a unicolor screen with one of the standard progress indicators?
any inputs?
Edit: I managed to drop the loadingtime from apprx 3 seconds to a few milliseconds so i wont need it in this particular project, but anyways i think its a question worth asking =) so im still very interested in ideas =)
i already read this tutorial: Using AlertView For Progress Indication but i was not able to adapt it in a little testproject to use during view transitions.
sebastian
You can set any placeholder view you like in
viewWillAppear, then spawn off a background block to load the content. After the content is loaded, you update the screen to show them:A few notes:
[self isStillNeeded]is needed since the data is being loaded in the background, and the view might no longer be on the screen when the loading is completed (e.g. the user may have navigated away). How do you check this depends on exactly how your application works. In some cases, it may be as simple as checking whether the view still has asupervieworwindow.Make sure any interface update happens on the main thread (hence the dispatch to
dispatch_get_main_queue()as this is required by the OS.