Collection View Layout Bug When Selectitem (Swift 5)

Collection View layout bug when selectItem (Swift 5)

You need to cut insets and spacing from cell width:

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = (collectionView.frame.width/2.2) - 2*12 - 11
return CGSize(width: width, height: 55)
}

CollectionView not displaying 3 columns as expected

You can try this

let screenWidth = self.CollecionView.frame.width
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: (screenWidth/3)-5, height: (screenWidth/3)-5)
self.CollecionView.collectionViewLayout = layout

Collection view cell slow detect selected item in swift

I fixed the problem after delete this code on AddViewController.

let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(AddExpenseVC.dismissKeyboard))
view.addGestureRecognizer(tap)

@objc func dismissKeyboard() {
view.endEditing(true)
}


Related Topics



Leave a reply



Submit