如何在swift中获取集合视图的标题?
答
由于iOS的9,你可以使用:
func supplementaryView(forElementKind elementKind: String,
at indexPath: IndexPath) -> UICollectionReusableView?
度日指数路径的补充视图。
答
您可以使用:
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)
}
是的,我得到头的didSelectItemAtIndexPath但收集滚动视图时,那之后选择任何项目,然后它给空值,而不是头。因为我觉得这部分不在队列中。 –
这很正常,您的标题不可见! –
你有什么想法,那是什么解决方案? –