Let.Simoo
Let.Simoo

Reputation: 93

Can I share same Cell of UICollectionView with UITableView?

I have created a cell.xib which is already subclass of UICollectionView already.

Later I decided to create a TableView in another ViewController... I wrote the code and everything except registering the cell I was unable to register the cell which is subclass of collectionView (which is registered already inside collectionView in other page) inside the TableView!

I got this warning or error

Can I share same Cell of UICollectionView with UITableView?

So, Please anyone can help me and tell me how to do it in the right way?

Upvotes: 0

Views: 293

Answers (1)

Tomo Norbert
Tomo Norbert

Reputation: 780

The problem is that FproductsCell is not a sublcass of UITableViewCell and thats why you get the error.

Create your UITableViewCell subclass in a xib and from this point, you have to register it to every UITableView where you want to use this cell in, programatically. Your class has to be inherited from UITableViewCell

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.register(YourCell.self, forCellReuseIdentifier: "YourIdentifier")
}

Upvotes: 1

Related Questions