Я хочу добавить нижний колонтитул в UICollectionView
, используя этот код. Я использую Использование пользовательского макета в макет UICollectionViewUICollectionview footer in swift
Добавлен делегат и DataSource методы: -
UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
Код в viewdDidLoad()
функции: -
UINib(nibName: "ProfileFooter", bundle:nil)
collectionView!.registerNib(nibName1, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: "ProfileFooter")
collectionView.registerClass(ProfileFooter.classForCoder(), forSupplementaryViewOfKind: "ProfileFooter", withReuseIdentifier: "ProfileFooter")
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
var reusable = UICollectionReusableView()
if kind == UICollectionElementKindSectionFooter{
let ProfileFooter = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: "ProfileFooter", forIndexPath: indexPath)
ProfileFooter.backgroundColor = UIColor.redColor()
reusable = ProfileFooter
}
return reusable
}
может любой проверить, что случилось в это ??
Почему вы написали как registerNib, так и registerClass? удалите строку registerNib. –
Я проверил, что оба они все еще не работают ... – Ravi
Запишите строку registerClass следующим образом: 'registerClass (ProfileFooter, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier:« ProfileFooter »)', а также еще раз проверить идентификатор нижнего колонтитула правильно или нет , –