Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UIActivityIndicator on UITableView header. ( >= iOS6 )
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UITableViewHeaderFooterView *sectionHeaderView = nil;
if (section == 1) {
sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headerIndicatorView"];
if (sectionHeaderView == nil) {
sectionHeaderView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"headerIndicatorView"];
}
float indicatorSize = 21.0f;
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(120, 7, indicatorSize, indicatorSize)];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[sectionHeaderView.contentView addSubview:activityIndicator];
[activityIndicator startAnimating];
}else{
sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"defaultHeader"];
if (sectionHeaderView == nil) {
sectionHeaderView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"defaultHeader"];
}
}
return sectionHeaderView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.