我在视图控制器中使用了UICollectionView
并传递了一组图像。我已启用收集视图的分页。但是当我滚动到下一张图像时,以前的单元格不会完全消失。它仍然处于边缘。所以,how I can make only specific image/cell visible while scrolling left/Right.
如何在UICollectionView中显示特定单元格的矩形
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == collection_LargeView
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Large Cell", for: indexPath)as! LargeImageCell
cell.imageView_LargePic.sd_setImage(with: NSURL(string: array[indexPath.row]) as URL!)
cellIndex = indexPath
return cell
}
else
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Picture Cell", for: indexPath)as! VendorPictureCell
cell.imageView_VendorPics.sd_setImage(with: NSURL(string: array[indexPath.row])as URL!)
return cell
}
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return array.count
}
//当在底部收集视图项目选择了其他集合视图滚动到indexPath
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView == collectionView_picturesCollection
{
Index = indexPath.row
collection_LargeView.scrollToItem(at: indexPath, at: .right, animated: true)
}
}
请解决这个问题。 谢谢。
After scrolling from one cell to next Screenshot : https://i.stack.imgur.com/msmnV.jpg
给我集合视图的屏幕截图 –
能否请你在这里更新的代码,你是使用? – SNarula
https://i.stack.imgur.com/msmnV.jpg –