0
私は、コレクションビューのセル名をアルファベット順でプロジェクトで実行しています。インデックス関数collectionViewを実現しようとしています。開始する...SwiftのIndexed CollectionView
ありがとうございました。
私は、コレクションビューのセル名をアルファベット順でプロジェクトで実行しています。インデックス関数collectionViewを実現しようとしています。開始する...SwiftのIndexed CollectionView
ありがとうございました。
BDKCollectionIndexViewは、問題の解決に最適です。
https://github.com/kreeger/BDKCollectionIndexView
これは基本的にのUITableViewと同様のインデックスUIを作成します。
これは作成者が投稿したコード例です。
override func viewDidLoad() {
super.viewDidLoad()
let indexWidth = 28
let frame = CGRect(x: collectionView.frame.size.width - indexWidth,
y: collectionView.frame.size.height,
width: indexWidth,
height: collectionView.frame.size.height)
var indexView = BDKCollectionIndexView(frame: frame, indexTitles: nil)
indexView.autoresizingMask = .FlexibleHeight | .FlexibleLeftMargin
indexView.addTarget(self, action: "indexViewValueChanged:", forControlEvents: .ValueChanged)
view.addSubview(indexView)
}
func indexViewValueChanged(sender: BDKCollectionIndexView) {
let path = NSIndexPath(forItem: 0, inSection: sender.currentIndex)
collectionView.scrollToItemAtIndexPath(path, atScrollPosition: .Top, animated: false)
// If you're using a collection view, bump the y-offset by a certain number of points
// because it won't otherwise account for any section headers you may have.
collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x,
y: collectionView.contentOffset.y - 45.0)
}
この質問も可能である重複: SectionIndexTitles for a UICollectionView