728x90
๋ฐ์ํ
์๋ ํ์ธ์ Foma ๐ป ์ ๋๋ค!
์ค๋ ๋ง๋ ์๋ฌ๋ ๋ฐ๋ก ์์ ๊ฐ์ด 'NSInternalInconsistencyException' ์ค๋ฅ ์์ต๋๋ค.
์ด๊ฒ ๋ฌด์จ ๋ง์ด๋๋ฉด ์ปฌ๋ ์ ๋ทฐ์์ ReusableView๋ฅผ ์ฌ์ฉํ๋๋ฐ dequeReusableCell๋ก ๋ณดํต๊ณผ ๊ฐ์ด ์ธํ ํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
์ ์ฝ๋๋ฅผ ๋ณด๋ฉด ์๋์ ๊ฐ์ด ์ปฌ๋ ์ ๋ทฐ ํค๋์ ํธํฐ๋ฅผ ReusableView๋ก ๋ง๋ค์ด์ ์ธํ ํ๋๋ฐ์.
์๋์ ๊ฐ์ด dequeํ๋ ๋ถ๋ถ์ด ์ผ๋ฐ ์ ๊ณผ ๊ฐ์ด dequeReusableCell๋ก ๋์ด์์ต๋๋ค.
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader{
let cell = collection.dequeueReusableCell(withReuseIdentifier: "VoiceChatCreateHeaderCollectionViewCell", for: indexPath) as! VoiceChatCreateHeaderCollectionViewCell
cell.bind(reactor: reactor)
return cell
}else {
let cell = collection.dequeueReusableCell(withReuseIdentifier: "VoiceChatCreateFooterCollectionViewCell", for: indexPath) as! VoiceChatCreateFooterCollectionViewCell
cell.bind(reactor: reactor)
return cell
}
}
ํด๊ฒฐ๋ฒ์ ์๋์ ๊ฐ์ด dequeReusableCell๋ฅผ dequeReusableSupplementaryView๋ก ํด์ฃผ์๋ฉด ๋ฉ๋๋ค.
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader{
let cell = collection.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "VoiceChatCreateHeaderCollectionViewCell", for: indexPath) as! VoiceChatCreateHeaderCollectionViewCell
cell.bind(reactor: reactor)
return cell
}else {
let cell = collection.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "VoiceChatCreateFooterCollectionViewCell", for: indexPath) as! VoiceChatCreateFooterCollectionViewCell
cell.bind(reactor: reactor)
return cell
}
}
728x90
๋ฐ์ํ
๋๊ธ