Reputation: 11700
I have a tab bar application. I have 2 questions.
Using a default image for the application does that enable the application to initialize itself (the first view that is showed in MainView.xib) in the background while the image is being displayed?
Touching the second tab in the
application, the application will
load data into a UITableView
. This
takes some time (fetching some data
from the internet) so going from the
first tab to the second tab there is
a delay before the table is being
showed in the second tab. I want to
display a UIActivityIndicatorView
while
the UITableView
is being populated
and then want the
UIActivityIndicatorView
to disappear
when the UITableView
is finished
loading. How can I achieve this?
Upvotes: 2
Views: 9653
Reputation: 10303
You can use this inside the activity:
protected Dialog onCreateDialog(int id) {
ProgressDialog progress = new ProgressDialog(this);
progress.setMessage("The information is gathered, one moment please.");
progress.setIndeterminate(true);
progress.setCancelable(false);
progress.setCanceledOnTouchOutside(false);
return progress;
}
This will show an alert once you call this in(or on) the activity:
showDialog(0x0001);
When the dialog has to fade out call this:
removeDialog(0x0001);
EDIT
Now for objective-c:
UIAlertView alert = [UIAlertView initWithTitle:@"a title" message:@"a message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]
[alert show];
if(alert != nil) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height-45);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];
}
EDIT Removing it is done with this:
[alert dismissWithClickedButtonIndex:0 animated:YES];
[alert release];
/EDIT
That worked for me:) it could be its not totally spot on becouse i changed some stuff in the browser to now thow company secrets etc xD :). Feel free to ask stuff about it.
Upvotes: 10
Reputation: 51374
YES. Even if you don't give any default image, it will load the first view controller showing a black screen.
Display the activity indicator view in your second view controller's loadView
. And, put all the loading code in your second view controllers viewDidAppear:
method. By doing this, your second view controller will be displayed with the activity indicator view as soon as you press the second tab. And after the loading is completed, dismiss the activity indicator. This will give you a smooth transition from one tab to the other.
Upvotes: 3