I have a prototype cell in a Storyboard. Is there any quick and easy method for me to extract that to its own .xib
file so that I do not need to create .xib
from scratch? Thanks.
CodePudding user response:
Go to File -> New -> File... in the Xcode menu and select the "Empty" template from under the "User Interface" section. This creates an empty xib file.
Select the prototype cell from the storyboard, press ⌘C to copy the cell. Go to the newly created xib file, press ⌘V to paste the cell.
In your code, you should remember to register the xib file with the table view:
tableView.register(
UINib(nibName: "YourXibFileName", bundle: nil),
forCellReuseIdentifier: "yourCellId"
)
Now you can delete the cell in the storyboard.