I have a RecyclerView
(with a GridLayoutManager
) that has 4 different view types. In a phone portrait layout, every view type should display 1 item per row. However, one view type (a card) can display two cards per row if the device width is large enough (i.e. tablet).
Does iOS have a similar layout API like RecyclerView
to allow something this flexible? If so - what is it?
Example (more columns in tablet vs phone)
TableView and RecyclerView In iOS, TableView is the fundamental UIView that shows a list of items and its cell can be recycled for memory efficiency purpose.
RecyclerView is the ViewGroup that contains the views corresponding to your data. It's a view itself, so you add RecyclerView into your layout the way you would add any other UI element. Each individual element in the list is defined by a view holder object.
Use UICollectionView to achieve this
Yes, not just similar pattern but it also reuse the views:
RecyclerView -> UICollectionView Adapter -> UICollectionViewDataSource ViewHolder -> UICollectionViewCell LayoutManager -> UICollectionViewLayout
Several views are currently optimized for performance and resource use, like:
UICollectionView
UITableView
viewControllers
UIPageViewController
UITabBarController
UIStackView
Probably you need the UICollectionView
for your proyect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With