简体   繁体   English

iOS静态表视图不是那么静态

[英]iOS static table view not so static

I'm developing a static grouped table view with storyboard. 我正在开发带有情节提要的静态分组表视图。 Anyway, sometimes I'd like not to display some of the rows. 无论如何,有时候我不想显示一些行。 As long as the rows I want to hide are in the middle, I can set the height of that specific cell to 0 and the trick works :) 只要我要隐藏的行在中间,我就可以将该特定单元格的高度设置为0,这样就可以了:)

Anyway, when I want to hide the last cell of a group (I'm using a grouped table view), my trick obviously does not work. 无论如何,当我想隐藏组的最后一个单元格时(我正在使用分组表视图),我的技巧显然不起作用。 That's because the previous cell won't get the round corners typical of the last cell. 那是因为前一个单元格不会得到最后一个单元格的圆角。 Is there another trick that can help me with this issue? 还有其他技巧可以帮助我解决此问题吗?

I solved my problem implementing the method 我解决了实施该方法的问题

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

even if I'm using a static table view. 即使我使用的是静态表格视图。

The proper way to remove a cell from a table view after it has been rendered is to use the UITableView method called deleteRowsAtIndexPaths:withRowAnimation: . 渲染完单元格后,从表格视图中删除单元格的正确方法是使用称为deleteRowsAtIndexPaths:withRowAnimation:的UITableView方法。 Here is a code sample: 这是一个代码示例:

[tableView deleteRowsAtIndexPaths:@[myCellIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

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

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