2017-11-01 3 views
0

매개 변수 인수로 스크롤 위치에 대한 옵션 집합을 전달하려고하지만 문제가 발생했습니다.scrollpositions에 대한 매개 변수로 옵션 세트를 전달하는 방법은 무엇입니까?

누구든지 어떻게 작성 할 수 있습니까?

func selectCurrentWallpaperCell() { //want to pass parameter here 
     let currentWallpaperID = self.wallpaperManager.currentWallpaperID 
     if let index = self.wallpapers.index(where: { $0.id == currentWallpaperID }) { 
      let indexPath = IndexPath(item: index, section: 0) 
      self.collectionView.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition()) // how to use in scrollposition? 
     } 
    } 

답변

4
let options: UICollectionViewScrollPosition = [.top, .centeredVertically] 
self.collectionView.selectItem(at: indexPath, animated: true, scrollPosition: options) 

참조 : OptionSet

0

UICollectionViewScrollPositionOptionSet 프로토콜을 준수하고 Suhit 이미 대답 것처럼 따라서 두 개 이상의 옵션을 전달할 수 있습니다.
그냥 인자로 UICollectionViewScrollPosition을 수락하고 매개 변수로 collectionview의 selectItem : 메소드에 전달하면됩니다.

관련 문제