【发布时间】:2021-08-05 10:21:14
【问题描述】:
我是 iOS 开发的新手。目前,我正在做一个项目,其中我在单个视图控制器中使用了两个以上的UITableViews,但是两个数据源一个一个地来自服务器。当第一个 api 命中时,它会显示结果,但在从该列表中选择项目后,我无法在列表中显示响应。
这是我的代码:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("sdfsdfsf")
var count:Int?
if tableView == self.pat_search_listview {
count = serach_data.count
}
else if tableView == self.visit_listview {
count = all_vist_data.count
}
return count!
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
if tableView == self.pat_search_listview {
cell.textLabel?.text = serach_data[indexPath.row].name + " " + serach_data[indexPath.row].id
}
else if tableView == self.visit_listview {
print("second listview")
cell.textLabel?.text = all_vist_data[indexPath.row].date
}
return cell
}
【问题讨论】:
-
它是正确的。这段代码面临什么问题?
-
你在屏幕上看到的是哪一个tableView?
-
问题是它在第二个 uitableview 中什么都不显示
-
ite 不显示任何内容
-
@PardeepKumar 这条线
print("second listview")被执行了吗?
标签: ios swift xcode uitableview