In my iPhone app how could I create a UIAlert (or some other indicator) that highlights to the user that the data is loading such that:
- starts as soon as the user selects a cell in UITableViewController A, and
- ends after UITableViewController B is actually displayed
The rough flow I have would be then:
- Controller A
- User selects row
- Alert starts
- Data loaded in preparation for controller B
- Controller B
- in say viewDidLoad turn off the loading indicator
Need to find a way to do this such that the “loading” indicator used is actually displayed on the current view straight away…
The way I personally would go about this would be to first assign an alert in the header file:
then create and present the alert in the
tableView:didSelectRowAtIndexPath:method.Then to dismiss the view, simply do so in your
viewWillDisappear:animated:method with a call like the following:This should ensure that the alert is dismissed before the next view is presented. I hope this helps. If you have any questions, I’d be happy to describe in more detail
EDIT: in order to dismiss the alert from a different view, you will have to create a method where you create the alert to dismiss it, import the header into the view which it is pushing to, find the parent view from the child, then dismiss when you want. I will explain in detail below. So first, create a method to dismiss the view from the parent, which I will just refer to as Parent
In the view which you push to, be sure to put
#import "Parent.h"at the top of the implementation file.Now it’s just a matter of finding the view and calling the method. You can change where this is called, but for example purposes, I’m just going to start a timer in the
viewDidAppear:method in the Child file and go from there.Then create the
dismissmethodI have tested this and it does work, so hopefully it does the trick for you. You can change the time interval to your pleasing. Considering I don’t know the heirarchy of your app, it’s hard to say where the Parent view is located with respect to the Child, but you can play around to find it if the above isn’t it.