iOS UITableView中的HeaderSection、FooterSection不悬浮、停留 设置
方式一:
修改tableView的style为UITableViewStyleGrouped
如:
self.tableView = [[UITableView alloc] initWithFrame:frame
style:UITableViewStylePlain];
方式二:(普遍推荐)
在创建tableView之后(同时设置HeaderSection、FooterSection)
self.headerViewHeight = 30;
self.footerViewHeight = 5;
self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.headerViewHeight)];
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.footerViewHeight)];
self.tableView.contentInset = UIEdgeInsetsMake(-self.headerViewHeight, 0, -self.footerViewHeight, 0);
在创建tableView之后(设置HeaderSection)
self.headerViewHeight = 30;
self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.headerViewHeight)];
self.tableView.contentInset = UIEdgeInsetsMake(-self.headerViewHeight, 0, 0, 0);
在创建tableView之后(设置FooterSection)
self.footerViewHeight = 5;
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.footerViewHeight)];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, -self.footerViewHeight, 0);