我是iOS开发新手。目前,我正在开发一个项目,在该项目中,我在单个视图控制器中使用了两个以上的UITableView
,但这两个数据源都来自服务器。当第一个API弹出时,它显示结果,但是从该列表中选择项目后,我无法在列表中显示响应。如何在单一视图中使用多个UITableView控制器在iOS中 - Swift
这里是我的代码:提前
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
}
感谢
它是正确的。这个代码面临什么问题? – KKRocks
您在屏幕上看到的tableView中的哪一个? –
的问题是,它显示没有在第二个uitableview –