当我们有 UICollectionView 时,我们应该使用 UITableView 吗?
我已经使用过 UICollectionView 和 UITableView 及其微不足道的使 UICollectionView 看起来像表格.更重要的是使用模式非常相似,你不必学习很多新东西来使用它.
I have worked with both UICollectionView and UITableView and its trivial to make UICollectionView look like table. What is more usage patterns are very similar, you don't have to learn a lot of new stuff to use it.
问题是使用 UITableView 而不是 UICollectionView 有什么论据吗?或者我们可以切换到 UICollectionView 而忘记 UITableView?
The question is are there any arguments for using UITableView and not UICollectionView? Or we can just switch to UICollectionView and forget about UITableView?
我不这么认为.
例如,如果您想要一些即时贴标头,您必须为您的 UICollectionView
创建自定义布局,而使用 UITableView
则非常容易.
For example, if you want to have some stickies header, you've got to create a custom Layout for your UICollectionView
, whereas, it's really easy with UITableView
.
此外,您还有 plain
和 group
tableViews,这非常有用.
Moreover you have plain
and group
tableViews, which is really usefull.
在我个人看来,我会说有时最好是相互化并使用 collectionView(例如,如果它是 iPhone 上的 tableview 和 iPad 上的 collectionView),但不是每次都如此.
In my own opinion, I would say sometimes it's better to mutualize and use a collectionView (if it's a tableview on iPhone and a collectionView on iPad for instance), but not everytime.