Skip to content

Instantly share code, notes, and snippets.

@akimach
Last active June 9, 2016 06:29
Show Gist options
  • Select an option

  • Save akimach/4d258973b841bc561d42c431c12dfd16 to your computer and use it in GitHub Desktop.

Select an option

Save akimach/4d258973b841bc561d42c431c12dfd16 to your computer and use it in GitHub Desktop.
UICollectionViewDataSource

UICollectionViewDataSource

Required

  • func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
  • あるセクションのセル数
  • func collectionView(_ collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
  • セルの内容

Optional

  • optional func numberOfSectionsInCollectionView(_ collectionView: UICollectionView) -> Int
  • セクション数
  • optional func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView
  • 補助的なビューの内容
  • optional func collectionView(_ collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool
  • セルが移動可能かどうか
  • optional func collectionView(_ collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath)
  • 移動された際の処理

UICollectionViewDelegate

  • optional func collectionView(_ collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool
  • デリゲートにメッセージを送るかどうか
  • optional func collectionView(_ collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
  • タップされたセルを伝える
  • optional func collectionView(_ collectionView: UICollectionView, shouldDeselectItemAtIndexPath indexPath: NSIndexPath) -> Bool
  • タップされなくなったセル
  • optional func collectionView(_ collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath)
  • タップされなくなっセルを伝える

UICollectionViewDelegateFlowLayout

  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
  • セルのサイズ
  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets
  • セクションの余白
  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat
  • セクションの余白
  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat
  • セル間の余白
  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize
  • ヘッダのサイズ
  • optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize
  • フッタのサイズ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment