简体   繁体   English

UITableview显示有限的单元格

[英]UITableview displays limited cells

I have a UITableView that is setup correct and at some point I wanted to display only a limited amount of cells. 我有一个设置正确的UITableView,在某些时候我只想显示有限数量的单元格。 Now that I want to revert back the functionality I am unable to do so. 现在,我想还原功能,因此我无法这样做。

The property that limits the visible cells (according to my git log): 限制可见单元格的属性(根据我的git日志):

// This will remove extra separators from tableview
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

After removing the above line, I still do not get the desired effect. 删除上述行后,我仍然没有得到预期的效果。

But something was introduced, and I am not sure what to search for. 但是引入了一些东西,我不确定要搜索什么。

I want the default behavior back with many empty cells. 我希望默认行为返回许多空单元格。

Here is my methods for the sections and data, currently I only have two cells visible. 这是我用于部分和数据的方法,当前我只有两个可见的单元格。

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [data count];
}

View Hierarchy Debugging data. 查看层次结构调试数据。

I am adding images of the View Debugger, "Wire Frame View" and "Content View" seperately. 我分别添加了视图调试器,“线框视图”和“内容视图”的图像。

From the images you will see two types of separator lines; 从图像中,您将看到两种分隔线: I mimicked a line by adding space at the bottom of the cell so that I could have "thin lines". 我通过在单元格底部添加空间来模仿一条线,以便获得“细线”。

线框视图

内容检视

Please check the tableview height . 请检查tableview height I think height of the table currently you are seeing is less so you are getting only 2 visible cells. 我认为您当前看到的桌子高度较小,因此您只能看到2个可见单元格。

As one can see from the attached images, the wire frames show that the separators are in fact drawn but they are not visibly on the screen when you view the content. 从所附图像中可以看到,线框显示分隔符实际上是绘制的,但是当您查看内容时它们在屏幕上不可见。

Simply change the colors: 只需更改颜色:

  self.tableView.backgroundColor = [UIColor redColor];
  self.tableView.separatorColor = [UIColor greenColor];

If possible in your case instead of adding footer view, try changing the height of table view. 如果可能,请尝试更改表格视图的高度,而不是添加页脚视图。 When number of cells are limited set tableview height small till number of cells and increase the height in second scenario. 当单元数受到限制时,将tableview的高度设置为小至单元格数,然后在第二种情况下增加高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM