I am having problems when I try to select an element inside a UICollectionView, because when I click on it, it scrolls a bit.
I know that calledSelectItemAtIndexPath is called, but I want to prevent scrolling when selected. I just want the collection view to be viewed when the user scrolls, but if the user just clicks on a cell, he should not move. Only need to choose.
I hope you can help me, since I do not know how to prevent this problem.
Any help would be really appreciated.
collectionview.selectItem(at: indexpath, animated: true, scrollPosition: .top) - , , ...
collectionview.selectItem(at: indexpath, animated: true, scrollPosition: .top)
... , , , , , : collectionview.selectItem(at: indexpath, animated: true, scrollPosition: [])
collectionview.selectItem(at: indexpath, animated: true, scrollPosition: [])
, , CollectionView , . , , CollectionView .
:
collectionView.selectItem(at: newIdexPath, animated: true, scrollPosition: UICollectionViewScrollPosition(rawValue: 0))
5
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) }
Objective-C
[self.collectionView selectItemAtIndexPath:path animated:NO scrollPosition:UICollectionViewScrollPositionNone]
Swift
collectionview.selectItemAtIndexPath(indexPath: path, animated: false, scrollPosition: None)
Source: https://habr.com/ru/post/1618528/More articles:Crash in Java Collections.sort? The first time it starts, it takes up to 50 times until the next time - java"Map" of a nested list in Python - pythonHtml text field without model in Yii2 - yii2Convert pandas data to list - pythonСумма цифр числа в sql-сервере без использования традиционных циклов, например while - sql"Resource never closes" in try-with-resources when chaining methods - javaпакетная обработка таблицы данных С# - c#How to save image in your local folder using Angular.js and PHP - javascriptmscorlib.dll messed up my gated TFS assembly - c #Как получить Pandas имена столбцов multiindex в виде списка - pythonAll Articles