【发布时间】:2016-11-11 02:58:36
【问题描述】:
我遇到了一个问题,viewForSupplementaryElementOfKind 委托函数从未检测到 UICollectionElementKindSectionFooter。
因此,创建了页眉,但从未创建过页脚。
我还实现了委托referenceSizeForHeaderInSection 和referenceSizeForFooterInSection 方法。
我也注册了NIB。
collectionView.register(UINib(nibName: "FooterCollectionReusableView", bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: "footerIdentifier");
collectionView.register(UINib(nibName: "HeaderCollectionReusableView", bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerIdentifier");
这是不工作的代码。
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
var view: UICollectionReusableView! = UICollectionReusableView();
switch kind {
case UICollectionElementKindSectionHeader:
print("HEADER DETECTED");//CALLED
break;
case UICollectionElementKindSectionFooter:
print("FOOTER DETECTED");//NEVER CALLED
break;
default:
break;
}
return view;
}
谁能帮帮我?
P.S.:我读过有人说在collectionView 的布局中设置footerReferenceSize 会起作用,但我试过了,它也不起作用
【问题讨论】:
标签: ios uicollectionview swift3 uicollectionviewcell uicollectionviewlayout