To create a UITableView
with models and designated cells in Swift, you can follow these steps:
main.swift213 chars10 lines
Create a new file for your custom cell. You can create a .xib
file for your cell or create a custom subclass of UITableViewCell
in your project.
In your UIViewController
, create an IBOutlet
for your UITableView
.
main.swift43 chars2 lines
UIViewController
, create an array to hold your Item
models.main.swift21 chars2 lines
viewDidLoad()
, register your custom cell to the table view and set the dataSource and delegate to the view controller.main.swift242 chars9 lines
UITableViewDataSource
methods in your view controller to retrieve and display the data in your UITableView
.main.swift577 chars17 lines
UITableViewDelegate
method didSelectRowAt
to handle user interaction with the table view.main.swift192 chars6 lines
With these steps, you should now have a UITableView
with models and designated cells in Swift.
gistlibby LogSnag