Reputation: 4259
I want to create same CustomCell
for UICollectionView
and UITableView
. But I don't want to create different CustomCells for this both.
So How can I use same UIView
for this cells.?
I want to create following screens into my application.
Is there any solution for this.?
Any help would be appreciated.
Upvotes: 1
Views: 207
Reputation: 2287
When dequeueReusableCell of collectionView or tableview.
1. Check if cell.contentView has subview of CustomView.
2. If not, create object of CustomView class and add as subview to cell.contentView
3. Fill CustomView with data.
Upvotes: 1
Reputation: 604
Create a .xib file for your CustomCell,
then just initialise it in your respective classes like:
UICollectionView.dequeueReusableCell()
UITableView.dequeueReusableCell()
Upvotes: 1