UITableView的HeaderView和FooterView


header通过下面两个代理方法设置

 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

footer通过下面两个

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

 

如果要做整个tableview的header和footer,要通过tableview setHeaderView setFooterView

 

如果只是指定每个section的title,只需要tableView的dataSource的实现下面的方法来返回每个section的title

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

 

-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

是用来自定义每个section的headView

 

 

如果是要自定义每个section的headView用第二个方法创建自定用的视图并返回。

-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

if(section == 0) { CustomView *view = [[CustomeView alloc] init]; return [view autorelease]; }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM