【发布时间】:2014-07-25 16:21:55
【问题描述】:
我发现这个问题之前在堆栈溢出和其他网站上也得到了回答。我尝试了所有选项,但它们是桌子下方的空白。我的表格视图中有 4 个原型单元格。在情节提要上,它们在第 4 个单元格之后没有空格。但是在执行时,我在第 4 行之后发现了空白。他们在第 4 行之后不再是分隔符,但空白的白色仍然是他们的。 我尝试添加以下代码:
- (void)viewDidLoad {
[super viewDidLoad];
_menuItems = [[NSMutableArray alloc] initWithObjects:@"chats", @"visitors", @"agents", @"profile", nil]; //@[@"chats", @"visitors", @"agents", @"profile", nil];
self.tableView.tableFooterView = [UIView new]; //[[UIView alloc] initWithFrame:CGRectZero];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.menuItems count];
}
-(CGFloat)tableView:(UITableView *) tableView heightForFooterInSection:(NSInteger)section {
return 0.01f;
}
-(UIView *)tableView: (UITableView *) tableView viewForFooterInSection:(NSInteger)section {
return [UIView new];
}
为了使整个视图看起来正确,我为视图和表格视图设置了相同的背景颜色。除了这个白色区域外,一切看起来都很正常,
谁能帮我知道为什么我在最后一行之后仍然看到白色区域?非常感谢任何帮助。谢谢。
【问题讨论】:
-
你的table view的高度超过了四行的高度。
-
这是
UITableView的默认行为。您必须将表格视图的高度与单元格的高度相匹配才能获得所需的行为。 -
TableView 中的行高为 44。每个 TableViewCell 的行高设置为 51。我将 TableView 高度设置为 204(51*4),它们仍然是空间。
-
我将 TableView 的行高也设为 51,现在它们在最后一行下方没有白色区域。非常感谢。
标签: ios objective-c uitableview