views:

12

answers:

2

I have a TabBarApplication and in one view I load XML-data from an URL.

When I click the tab which shows the view with the UITableView and the data received from the XML I would like to show a Activity indicator.

  1. What is recommended here? Should I push a view just for showing the activity indicator. Today I run the XML-parsing code in the viewDidLoad. Perhaps if I run that code in viewWillAppear instead?

  2. Another question is if I should reload the XML-data each time the user switches back to the tab containing the UITableView with the XML-data. Or should I in some way which I don't know of check if it's already "fetched"?

Thank you!

A: 

This is my current code.

[self getEvents] does the XML-fething and takes like 2 seconds.

loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:loadingIndicator];
[loadingIndicator startAnimating];

 [self getEvents];

[loadingIndicator stopAnimating];
Fernando Redondo
A: 

My solution was that in the viewDidLoad add this:

 loadingIndicator = [[UIActivityIndicatorView alloc] init];
 loadingIndicator.frame = CGRectMake(140, 190, 37, 37);
 loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
 [self.view addSubview:loadingIndicator];

 [self performSelectorInBackground:@selector(loadIndicator) withObject:loadingIndicator];
 [self performSelectorInBackground:@selector(getXmlData) withObject:nil];
Fernando Redondo