[英]Pattern for no data in a section in collectionView/TableView
I am contemplating on what is the recommended way to display a notice that there is no data for a specific section in a collectionView/TableView 我正在考虑在collectionView / TableView中显示没有特定部分数据的通知的推荐方法
One way is to create a special cell and to put that in instead of the data cells. 一种方法是创建一个特殊的单元格并将其放入而不是数据单元格中。 That feels odd, since the "empty notice" cell doesn't correlate with the data, which means I would need to spread a lot of conditions in didSelectItem, configuring the cell, etc 这感觉很奇怪,因为“空通知”单元格与数据不相关,这意味着我需要在didSelectItem中传播很多条件,配置单元格等等
Using https://github.com/dzenbot/DZNEmptyDataSet is appropriate only when the entire view is empty, not in a specific section 仅当整个视图为空时才使用https://github.com/dzenbot/DZNEmptyDataSet ,而不是在特定部分
Another way would be (which is what I do now) to insert a UIView into the place where the data would be as a subview of the collectionview, But this also would require maintenance when reloading the data, scrolling, tapping. 另一种方法是(我现在正在做的)将UIView插入到数据将作为集合视图的子视图的位置,但是这也需要在重新加载数据,滚动,点击时进行维护。 Also this requires calculation of where to place the view, which means I need to change it per collectionview, since it is not part of the collectionviewlayout 这也需要计算放置视图的位置,这意味着我需要根据collectionview更改它,因为它不是collectionviewlayout的一部分
Is there a recommended pattern to deal with these situations? 是否有推荐的模式来处理这些情况?
Maybe you shouldn't have that section at all if the section contains empty data. 如果该部分包含空数据,可能根本就没有该部分。 Reduce section count by 1 at - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
datasource method and recheck the cell to be displayed during - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
datasource method. 将节数减少1 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
数据源方法并重新检查要显示的单元格- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
数据源方法。
In reply to you, I think you would have some type of "Add" button to add comments, photos, friends, etc. Make the option to add a comment or photo less obtrusive than taking an entire tableView row, and omit the comment or photo section, if there are no comments or photos. 在回复你的时候,我认为你会有一些类型的“添加”按钮来添加评论,照片,朋友等。选择添加评论或照片,而不是采取整个tableView行,并省略评论或照片部分,如果没有评论或照片。
If you put an "Add comment" or "Add photo" row while displaying details, users will likely get tired of unnecessarily reading that, as they use the app. 如果您在显示详细信息时添加“添加评论”或“添加照片”行,则用户可能会厌倦不必要地阅读,因为他们使用该应用程序。
Note that tableViews generally handle insertion in editing mode , and when not editing, no section is shown if it is empty . 请注意,tableViews通常在编辑模式下处理插入,而在不编辑时, 如果它是空的 , 则不显示任何部分 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.