Reputation: 384
I have a tableview contains xml parsed objects.
I want to implement activity indicator in this tableview ,if the data loading is completed activity indicator stops automatically.
How to do this?.
Thanks in advance
Upvotes: 2
Views: 1594
Reputation: 6392
I hope, UITableView's "- (void)endUpdates" could be best place to stop your indicator when everything is done with the table.
Upvotes: 0
Reputation: 6025
after finishing the parse operation, give a notification to the tableview class , in that method you can reload the tableView and also stop the activity indicator .
Upvotes: 0
Reputation: 10011
First of all you need to make an async call to get your xml data.
Start your activity indicator before making the call then in the delegate method when you receive the data stop the activity indicator the code looks something like this.
- (void)getAsyncData
{
// do something here......
[indicator startAnimating];
[NSURLConnection connectionWithRequest:urlRequest delegate:self];
}
#pragma mark -
#pragma mark NSURLConnection delegate
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:responseData];
xmlParser.delegate = self;
[xmlParser parse];
[xmlParser release];
[indicator stopAnimating];
}
Upvotes: 1