I have a collectionView cell that displays the cells horizontally. I only want a set number of cells to show on the screen and after the amount I want to display ...
or something to signify there are more cells available. I don't want the user to scroll to more cells
Because there are different screen sizes like iPhone 4/5/6/7/iPad etc.. I don't want to put an exact number of items to get displayed. Instead I want to to truncate the amount of items based on the screen size for eg. On an iPhone 7+ in .compact size class at least five cells can fit on the screen but on an iPhone 4 only three cells can fit on a screen and on an iPad probably 20 cells.
I imagine I'd do something like this:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//I know this is comparing an Int to a CGRect and it won't work
if items.count > UIScreen.main.bounds.width{
//stop count and display truncation dots ...
}
return self.items.count
}
How would I accomplish this?