2016-12-16 34 views

回答

2

由於iOS的9,你可以使用:

func supplementaryView(forElementKind elementKind: String, 
       at indexPath: IndexPath) -> UICollectionReusableView? 

度日指數路徑的補充視圖。

退房Apple's documentation

1

您可以使用:

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){ 
    let indexHeaderForSection = NSIndexPath(row: 0, section: indexPath.section) // Get the indexPath of your header for your selected cell 
    let header = collectionView.viewForSupplementaryElementOfKind(indexHeaderForSection) 
} 
+0

是的,我得到頭的didSelectItemAtIndexPath但收集滾動視圖時,那之後選擇任何項目,然後它給空值,而不是頭。因爲我覺得這部分不在隊列中。 –

+0

這很正常,您的標題不可見! –

+0

你有什麼想法,那是什麼解決方案? –

相關問題