我在視圖控制器中使用了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 –