I want to reuse my UITableViewCell to my UICollectionViewCell.
Until now, I always use 2 xibs, 1 for UITableViewCell
and 1 for UICollectionViewCell
and I think it's kinda waste.
I've tried to subclassing UIView
for the cell but it's not working.
A way to do this is by using reusable views. Here is a Github project that can help: NibDesignable
You can also do this without using the project I mentioned, but it does make it easier. You then create a UIView with a View nib and put all your UI into this as well as any code for setting the UI components. Then you create your UITableViewCell and UICollectionViewCell and then just use the view that you created. You can also use prototype cells in a Storyboard for CollectionView or TableView if you prefer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.