[英]Image not showing on my UIImageview after clicking on UICollectionview cell until scroll
[英]Why does my UICollectionView scroll up when clicking on a cell?
單擊UICollectionViewCell
時,我的UICollectionView
總是向上滾動一點。
我注意到如果將集合視圖插入設置為0(根本沒有插入)並且將contentInsetAdjustmentBehavior
為.never
則不會發生此行為。
不過,我還是希望有(在底部和頂部加上了8px的)對我的內容插入UICollectionView
沒有這種自動滾動。 我不確定為什么會發生這種行為,以及它與content inset屬性到底有什么關系。
有沒有一種方法可以使自定義插入物不會在每次點擊UICollectionViewCell
時導致滾動?
這是我在viewDidLoad()
配置:
self.collectionView?.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
// self.collectionView?.contentInsetAdjustmentBehavior = .never
// When setting the contentInset to zero and the contentInsetAdjustmentBehavior to never, it does not scroll
VC看起來像這樣:
每個單元格代表一條消息。 底部的視圖是inputAccessoryView
。
當我刪除inputAccessoryView
時,不會發生此行為。 這也可能與以下討論有關: https : //forums.developer.apple.com/thread/18424
答案-閱讀評論
我的懷疑是布局問題。 要更正此問題,需要靜態設置布局,以免在與之交互時對其進行調整。 通常可以在約束條件下完成,在這種情況下,可以通過inputAccessoryView
設置CollectionView
偏移量的高度來解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.