我正在使用 xCode 4.3.2。在这个项目中,当我通过单击按钮调用“reloadXMLdata”时,它没有显示activityIndicator,在加载时它看起来像“挂起”,几秒钟后它会填充数据。如何在加载时显示 activityIndicator?你能帮我解决这个问题吗?
-(void)loadXML
{
NSString *urlAddress = [NSString stringWithFormat:@"my_xml_url"];
NSURL *url = [NSURL URLWithString:urlAddress];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[xmlParser setDelegate:self];
BOOL success = [xmlParser parse];
if(success)
{
[self.activityIndicator setHidden:TRUE];
[self.activityIndicator stopAnimating];
[dataTable reloadData];
}
else
NSLog(@"Error!!!");
}
-(IBAction)reloadXMLdata:(id) sender
{
[self.activityIndicator setHidden:FALSE];
[self.activityIndicator startAnimating];
[self loadXML];
}