在ViewController;
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
var tableView:UITableView!
var ctrls = ["A","V","B","C"]
override func viewDidLoad() {
super.viewDidLoad()
self.title = "主页面"
self.tableView = UITableView(frame:self.view.frame)
self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "ReusedCell")
self.view.addSubview(tableView)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.ctrls.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let id = "ReusedCell"
let cell = tableView.dequeueReusableCell(withIdentifier: id, for