Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add a PrototypeCell to UITableView inside xib file

I am new in IOS. I want to create a UITableView in a xib file instead of my Main.storyboard.
But the problem is when I drag a UITableViewCell in to UITableView, it does not work like in Main.storyboard.
My Main.storyboard now have many screen so it's very slow when load and also it's hard to find any screen. Therefore, I want to put put UITableView to xib file.

Do I miss something or I make something wrong?
Any help would be appreciated

Here is the describe image enter image description here

like image 653
Linh Avatar asked Dec 17 '15 10:12

Linh


People also ask

How do I load a Tableview cell in Xib?

h, a new subclass of UITableViewCell and add IBOutlets for the components you want. Then create a new "Empty XIB" file. Open the Xib file in IB, add a UITableViewCell object, set its identifier to "MyCellIdentifier", and set its class to MyCell and add your components. Finally, connect the IBOutlets to the components.

What is Uitableview in Swift?

A view that presents data using rows in a single column. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+


1 Answers

I'm sorry, but prototype cells are available only in storyboard-based projects. Hopefully you won't have gone too far down the xib approach and can try multiple storyboards instead. If you find them a bit overwhelming, it's OK; they get better – note that you don't have to have one storyboard for all your view controllers. You can have several, either linked in code or using storyboard references.

If you want to stick with xibs, another option is to use registerNib in code. So you design your prototype cells in xibs, then register them in code. Not quite as smooth, but it might suit your needs.

like image 56
TwoStraws Avatar answered Sep 21 '22 13:09

TwoStraws