ios - 无法从另一个 TableView 加载另一个 TableView

标签 ios swift uiviewcontroller segue

我设计了一个应用程序,它基本上有一个 tableview 有一个 rootView ,然后三个 Controller (2 个 tableviews 和 1 个 View Controller )旨在根据在 Root View Controller 上单击的行进行加载。我已将当前模态序列添加到 Root View Controller 的所有三个 View 中。但 View 没有被加载。我没有在 View 之间传递任何数据。仅加载 View 。我尝试加载 View 的代码是

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    NSLog("It did enter the didselectRowAtIndexPath")
    if (indexPath.section == 0){
        func prepareForSegue(segue : UIStoryboardSegue , sender : AnyObject?) {
                segue.destinationViewController as? DetailsViewController
               NSLog("Loading Details view controller")
            }
        }


    if (indexPath.section == 1){
        func prepareForSegue(segue : UIStoryboardSegue , sender : AnyObject?) {
            segue.destinationViewController as? AppCatalogViewController
            NSLog("Loading AppCatalog view controller")
        }

    }

    if (indexPath.section == 2){
        func prepareForSegue(segue : UIStoryboardSegue , sender : AnyObject?) {
            segue.destinationViewController as? supportViewController
            NSLog("Loading support view controller")
        }
}
   }

注意:“它确实输入了 didSelectRowAtindexPath”会打印在日志中。
谁能指导我应该做什么?提前谢谢您..

最佳答案

使用performSegueWithIdentifier:与prepareForSegue不同,prepareForSegue是在执行segue之前执行的,它用于对要呈现的 View Controller 进行一些设置。

关于ios - 无法从另一个 TableView 加载另一个 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418793/

相关文章:

ios - 快速创建 2 个可扩展行下拉菜单?

ios - 将参数从 sudzC ios 传递给 java webservice 始终为 null

ios - 分段控制和 ScrollView ,将 View 保存在内存中

ios - 如何在 swift 4 中使用 NSPredicate 过滤字典数组(Datewise)

ios - 将 UIViewController 推送到 UINavigationController 时动画挂起

ios - iOS 7 上的尺寸等级

ios - iOS 10 中的调用阻止功能

ios - 将本地通知角标(Badge)计数增加到 1

swift - 有没有办法根据之前是否在另一个 View Controller 上按下按钮来编写 if 语句?

ios - 在 TabBarController 应用程序中从另一个 ViewController 在 vi​​ewController 中设置属性是一种不好的做法