Created
April 29, 2013 05:55
-
-
Save iolate/5479930 to your computer and use it in GitHub Desktop.
UIActivityIndicator on UITableView header. ( >= iOS6 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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