我已经像以前的Xcode 8.1项目一样完成了所有工作... 但是,即使将其自定义,模拟器也会显示基本的空表行。 在viewdidload中尝试了一切,包括委托和数据源。
这是项目链接 https://drive.google.com/open?id=1hBR1cH5vr-sS4gLB-VBfF6iJPYKD59rd
(对不起,谷歌驱动器上传)
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var tblNames: UITableView!
var names = ["lonrvc","ktbfse","lnrset"]
override func viewDidLoad() {
super.viewDidLoad()
self.tblNames.delegate = self
self.tblNames.dataSource = self
self.tblNames.reloadData()
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return names.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! CustomTableViewCell
cell.lblName.text = names[indexPath.row]
self.tblNames.reloadData()
return cell
}
}
我只想在自定义单元格上显示数组(而不是在基本单元格上)