我有带标题( View 包含图像 + 标签)的 UIViewController
和带图像和标签的自定义单元格的 TableView 。
在 didSelectRowAt indexPath
中,我编写了这段代码来向另一个 View 显示按钮 Home
但是如果选择的按钮是 Offers
我想用新数据而不是原始数据重新加载 tableview
。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let revealViewController: SWRevealViewController = self.revealViewController()
let cell: MenuTableViewCell = tableView.cellForRow(at: indexPath) as! MenuTableViewCell
let MenuStoryboard = UIStoryboard(name: "Main", bundle: nil)
if cell.labelCell.text! == "Home"
{
let DestVC = MenuStoryboard.instantiateViewController(withIdentifier: "HomeVC") as! HomeVC
let newFrontVC = UINavigationController.init(rootViewController: DestVC)
revealViewController.pushFrontViewController(newFrontVC, animated: true)
}
// OffersTableVC
if cell.labelCell.text! == "Offers"
{
// reload a new data different from the original array
}
这可能吗?
最佳答案
像这样写代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell : TblCellTimeline = tableView.cellForRow(at: indexPath) as! TblCellTimeline
if indexPath.row == 0 {
// do code for home
}
else if indexPath.row == 1{
// do code for offer
}
:
:
else{
return
}
}
关于ios - 如何使用与原始数据不同的数据重新加载 TableView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41631884/