Collection view supplementary view not showing but i had implemented iOS swift
Problem:
I had registered supplementary view but it was not showing.Also it was not showing error rxswift.
My code as like below.
func setupRxBinding() {
//Collection bind
collDataSource = RxCollectionViewSectionedReloa
configureCell: { (_, collectionView, indexPath, item) in
// my cell configuration
})
model.items.bind(to: mycollView.rx.items(dataSource: collDataSource)).disposed(by: disposeBag)
mycollView.rx.itemSelected
.subscribe(onNext: { [weak self] indexPath in
}).disposed(by: disposeBag)
mycollView.rx.setDelegate(self).
collDataSource.
guard kind == UICollectionView.elementKindSe
fatalError("Unexpected supplementary view kind")
}
let headerView = collectionView.dequeueReusable
ofKind: kind,
withReuseIdentifier: "HeaderCell",
for: indexPath
) as! HeaderCell
return headerView
}
}
Solution:
Oh.Okay you are code is right.But you have to configureSupplementaryView before binding.Then onnly it will works.
func setupRxBinding() {
//Collection bind
collDataSource = RxCollectionViewSectionedReloa
configureCell: { (_, collectionView, indexPath, item) in
// my cell configuration
})
// this code
collDataSource.
guard kind == UICollectionView.elementKindSe
fatalError("Unexpected supplementary view kind")
}
let headerView = collectionView.dequeueReusable
ofKind: kind,
withReuseIdentifier: "HeaderCell",
for: indexPath
) as! HeaderCell
return headerView
}
model.items.bind(to: mycollView.rx.items(dataSource: collDataSource)).disposed(by: disposeBag)
mycollView.rx.itemSelected
.subscribe(onNext: { [weak self] indexPath in
}).disposed(by: disposeBag)
mycollView.rx.setDelegate(self).
}
You have to change the code as like above then it will works good..Happy coding....
Comments
Post a Comment