swift - 在 tableView 的单元格选择上打开重复的 viewControllers (swift)

标签 swift uitableview uiviewcontroller duplicates

我正在制作一个 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/

相关文章:

swift - 如何修复推送通知标题在 swift 中不显示正确的字符串

ios - 如何在 swift 3 中创建像 Alamofire 这样的自定义闭包

ios - UITableView 单元格有时无法更新图像,但滚动后显示正常

ios - scrollViewDidScroll 在设置表偏移后被调用 "twice"

iphone - UIViewController:检测向下钻取和向上钻取

ios - 如何在 tableview 中增加和减少标签的值,并在 swift 中根据标签值计算总价?

swift - 线程1 : Exception: “attempt to insert row 1 into section 1, but there are only 1 sections after the update”

ios - 解除多个 View Controller 的委托(delegate)问题

ios - 在当前 View Controller 下呈现新的 View Controller

ios - Socket.io监听方法在一段时间或失去Internet连接后不监听