I applied CircularSpinner loader to my tableview list. How can I hide the loader if the cell has been loaded? Now the loader will be appear for each access.
Sample code as below:-
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[CircularSpinner show:@"Loading" animated: TRUE type:CircularSpinnerTypeDeterminate showDismissButton:[NSNumber numberWithBool:TRUE] delegate:self];
[CircularSpinner setValue:0.4 animated: TRUE];
}
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
[CircularSpinner setValue:1.0 animated: TRUE];
}
}
EDITED:-
Here is function that I called API and setUpData will be called in ViewDidLoad.
-(void)setUpData{
[self.manager GET:@"http://api.XXX.com/api/announcement" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
_serverDataArr = responseObject;
self.dataArr=[NSMutableArray array];
for (NSDictionary *subDic in self.serverDataArr) {
Announcement_Model *model=[[Announcement_Model alloc]initWithDic:subDic];
[self.dataArr addObject:model];
}
_rowArr=[Events_DataHelper getFriendListDataBy:self.dataArr];
_sectionArr=[Events_DataHelper getFriendListSectionBy:[_rowArr mutableCopy]];
[self.tableView reloadData];
} failure:^(NSURLSessionTask *operation, NSError *error) {
// [CircularSpinner setValue:1.0 animated: TRUE];
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Please try again"
message:[error localizedDescription]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok"
style:UIAlertActionStyleCancel
handler:nil];
[alertVC addAction:okAction];
[self presentViewController:alertVC animated:YES completion:nil];
}];
}