swi*_*123 -4 uitableview ios swift
我的结构如下:
UIViewController -> UIVIew -> UITableView
tableView(_ tableView: UITableView, numberOfRowsInSection section: Int)
和
tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)
被称为但是
tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
不叫.
class ViewcontrollerA : UIViewController , UITableViewDelegate , UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.doctortableView.delegate = self
self.doctortableView.dataSource = self
self.doctortableView.allowsSelection = true
}
func callTable() {
doctortableView.frame = CGRect(......)
view1.addSubview(doctortableView)
doctortableView.isUserInteractionEnabled = true
self.view.addSubview(view1)
}
// Tableview Functions
// Number of Sections in Table
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var count = Int()
return count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = UITableViewCell()
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//This function is not called
}
}
Run Code Online (Sandbox Code Playgroud)
乍一看似乎是这个数据源方法的问题.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var count = Int()
return count
}
Run Code Online (Sandbox Code Playgroud)
不Int()归0?这意味着您的tableview没有任何单元格.
| 归档时间: |
|
| 查看次数: |
292 次 |
| 最近记录: |