Ios 删除页眉和页脚
我想从我的“UITableView”中删除页眉和页脚 我试过:Ios 删除页眉和页脚,ios,iphone,objective-c,uitableview,Ios,Iphone,Objective C,Uitableview,我想从我的“UITableView”中删除页眉和页脚 我试过: table.tableHeaderView = nil; - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ return nil; } - (CGFloat)tableView:(UITableView *)tableView heightFor
table.tableHeaderView = nil;
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section{
return 0;
}
但这些都不起作用。
我想从tableview的开头开始我的部分。当我尝试这样做时,通常结果是:
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section{
return [[UIView alloc] initWithFrame:CGRectZero];
}
请尝试下面的代码。这可能对你有帮助
-(CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section {
return 0.1;
}
-(CGFloat)tableView:(UITableView *)tableView
heightForFooterInSection:(NSInteger)section {
return 0.1;
}
您也可以通过设置
UITableView
@Vivek的contentInset
属性来实现这一点,只需删除所有不必要的实现方法也可以。我有相同的场景,但在页眉
和页脚
方面没有任何问题
我认为这只需要以下方法
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section{}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
这个怎么样:
- (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
试试这个:
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
- (UIView *)tableView:(UITableView *)tableView
viewForFooterInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
-(CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section {
return 0.1f;
}
-(CGFloat)tableView:(UITableView *)tableView
heightForFooterInSection:(NSInteger)section {
return 0.1f;
}
希望这对您有所帮助。删除这两种方法…@vivek尝试时发生了什么。尝试以下方法-(UIView*)tableView:(UITableView*)tableView for HeaderInSection:(NSInteger)section{return[UIView new];}@Zaph.。它只是显示了相同的结果@亚历山大 对只需将一个视图设置为tableView.tableHeaderView和tableView.tableFooterView属性。使用这两种方法…场景将与上面的屏幕截图一致…我使用的是tableView样式group@Vivek如果不需要,则使用简单表而不是分组表。