2017-05-09 51 views
0

我使用的是UICollectionView以示出陣列圖像的,水平並使用放大/縮小該圖像中的所述細胞與滾動視圖的幫助限制。但是當我水平滾動時,它會顯示當前單元格中以前的單元格內容。我無法確定問題所在。 enter image description hereUICollectionView顯示下一個單元之前的小區內容而滾動水平

enter image description here

的CollectionView數據源

enter image description here

CollectionCell類 enter image description here

+2

請分享一些代碼,以更好地瞭解...! –

+0

特別是你的'cellForItem(at:)'函數 – Paulw11

+0

在圖像單元內重寫「prepareForReuse」方法,並重置諸如 1)。 scrollViewForImage.zoomscale = 1 2)。 imageView.image = nil 3)。刪除圖像視圖中添加的點按手勢 應該修復問題 – vignesh

回答

0

試試這個,當你重用cellForItem的細胞在

cell.imageView.Image =零

+0

它不起作用! :( – Krimi

+0

cell.imageView.Image = nil cell.steupdata() –

+0

是啊!我做了完全一樣的,但它沒有解決我的問題 – Krimi

0

請分享一些代碼,以便我們可以幫助你更好。同時,請確保您有以下幾個部分代碼中的正常工作:

  • 註冊正確UICollectionViewCell子以正確的重用標識符
  • 使用方法[self.collectionView dequeueReusableCellWithReuseIdentifier:itemIdentifier forIndexPath:indexPath]和正確傳遞兩個參數。
  • 在UICollectionViewCell子類中,覆蓋prepareForReuse並在其中重置UI參數。

    覆蓋imageCell類中的prepareForReuse,並將imageView.image設置爲nil。

+0

我已經編輯了一些代碼我的問題請看看它 – Krimi

+0

圖像視圖在每個滾動中顯示正確的圖像,但內容大小滾動錯誤! – Krimi

+0

也許您需要'invalidateIntrinsicContentSize',重新計算大小,並調用'setNeedsLayout'。 –

0

滾動視圖的contentSize應該是大如imageView.image.size,或者只是使用MWPhotoBrowser

相關問題