Ячейка iOS Swift CollectionView сокращается - PullRequest
0 голосов
/ 03 июля 2018

мы используем UICollectionView для отображения некоторых данных. Моя проблема в том, что прокручиваемая ячейка horizontal ячейки выключается. Как это исправить?

Вот мой проверенный код:

func numberOfSections(in collectionView: UICollectionView) -> Int
{
   return 1
}

func collectionView(_ collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout,minimumInteritemSpacingForSectionAt section: Int) -> CGFloat
{
   return 1.0
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,minimumLineSpacingForSectionAt section: Int) -> CGFloat
{
   return 1.0
}

func collectionView(_ collectionView : UICollectionView,layout collectionViewLayout:UICollectionViewLayout,sizeForItemAt indexPath:IndexPath) -> CGSize
{
   let width = UIScreen.main.bounds.width
   return CGSize(width: width,height: collectionView.frame.size.height)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets
{
    return UIEdgeInsetsMake(0, 0, 0, 0)
    // top, left, bottom, right
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
   return 5
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
   let ViewSize = UIScreen.main.bounds.width
   let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CustomCell", for: indexPath as IndexPath) as! CSDashboardCustomCell
   cell.MainView.frame = CGRect(x: 10, y: 10, width: ViewSize - 40, height: 142)
   cell.MainView.backgroundColor = UIColor.white
   cell.MainView.layer.shadowColor = UIColor.lightGray.cgColor
   cell.MainView.layer.shadowOpacity = 1
   cell.MainView.layer.shadowOffset = CGSize.zero
   cell.MainView.layer.shadowRadius = 2
   cell.MainView.layer.cornerRadius = 6

   return cell
}

enter image description here

...