简体   繁体   English

UITableView vs UICollectionView vs UIScrollView?

[英]UITableView vs UICollectionView vs UIScrollView?

When should I use which, and what are the disadvantages or disadvantages of each?我什么时候应该使用哪个,每个的缺点或缺点是什么? I'm mainly confused with scrollview vs collectionview, I know tableview is limited to one column (I heard it gets messy when more than one column), but scrollview difference with collectionview seem the same to me.我主要对scrollview vs collectionview感到困惑,我知道tableview仅限于一列(我听说当超过一列时它会变得混乱),但scrollview与collectionview的区别对我来说似乎是一样的。

Both CollectionView & TableView are basically subclasses of UIScrollView.But as compared to UIScrollView here you are provided with proper methods to provide your dataSource & delegates to handle operations user performs on data. CollectionView 和 TableView 基本上都是 UIScrollView 的子类。但与 UIScrollView 相比,这里提供了适当的方法来提供数据源和委托来处理用户对数据执行的操作。 Along with this you are provided predefined layout classes.除此之外,您还提供了预定义的布局类。 Now to choose between them completely depends on your UI Requirements.现在在它们之间进行选择完全取决于您的 UI 要求。 Suppose you want to display just a list of items with a simple UI go with TableView.If you want a custom Layout like a grid or like the one you see in Apple's photo's app CollectionView is the choice.假设您只想显示带有简单 UI go 和 TableView 的项目列表。如果您想要像网格一样的自定义布局,或者像您在 Apple 的照片应用程序 CollectionView 中看到的那样,您可以选择。 if you have a complex UI & you have no idea about Custom CollectionView layout classes go with scrollView.如果您有一个复杂的 UI 并且您不知道带有滚动视图的自定义 CollectionView 布局类 go。

Consider UITableView and UICollectionView first and if you cannot achieve the effect you want with them, try UIScrollView then.先考虑 UITableView 和 UICollectionView ,如果你不能用它们达到你想要的效果,那么试试 UIScrollView 。 UIScrollView is more basic class. UIScrollView是比较基础的class。 UITableView and UICollectionView have more delegate method for us. UITableView 和 UICollectionView 为我们提供了更多的委托方法。 If you want a list,UITableView would be better.如果你想要一个列表,UITableView 会更好。 And if you want a multicolumn,use UICollectionView.如果你想要一个多列,使用 UICollectionView。

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

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