Creating cells with Swift is basically the same as creating cells with iOS, which is somewhat different in syntax. The call member method in Swift no longer uses [] to send a message, but instead uses the form of a. Member method to invoke the member function. This format is very similar to the point member operator in Java. References to other classes in Swift do not have to be imported into the header file. There's no nonsense here, now. The Pure code creation UITableView instance is as follows:
The concrete examples are as follows:
1. First create a project project with Swift
2. Create a person class with swift and generate the Person.swift file
3. Class The properties set in the Perosn.swift file.
4. The table code in the Viewcontroller.swift file is as follows:
Let the Viewcontroller class inherit the data source and proxy protocol, declaring both the array and the table view properties
Initialize the table view, create the data and add it to the array, set up the data source and the proxy, and finally add the table view to the view
Ways to implement a data source protocol
Methods of implementing Proxy protocol
//Demo results are as follows:
Start: When you tap a cell:
When you click a cell again, the previous cell marker is canceled, and the current cell is labeled
Swift: CREATE TABLE UITableView