我正在制作一个 TableView
,我希望每个单元格都打开一个我创建的 ViewController
的副本。
这可能吗?我已经搜索过了,但我真的找不到任何有用的东西。
最佳答案
举个例子:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
var viewController: UIViewController?
switch indexPath.row {
case 0:
viewController = ViewController0(nibName: "ViewController0", bundle: nil)
case 1:
viewController = ViewController1(nibName: "ViewController1", bundle: nil)
case 2:
viewController = ViewController2(nibName: "ViewController2", bundle: nil)
}
self.navigationController?.pushViewController(viewController, animated: true)
}
关于swift - 在 tableView 的单元格选择上打开重复的 viewControllers (swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39386196/