0

我正在尝试制作一个带有表格视图的视图容器。这很好,但是如果我选择最后一行,didSelectRowAt indexPath:则无法触发该方法。这是我的代码:

    let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
    let controller = storyboard.instantiateViewController(withIdentifier: "pageViewController") as! PageViewController
    addChildViewController(controller)
    controller.customDelegate = self
    controller.index = index
    self.controller = controller
    //Add Controllers
    let clientInfoVC = storyboard.instantiateViewController(withIdentifier: "ClientInfo") as! ClientInfoViewController
    clientInfoVC.client = self.client
    let clientRequestsVC = storyboard.instantiateViewController(withIdentifier: "ClientRequests") as! ClientProductRequestViewController
    clientRequestsVC.client = self.client
    let clientDebtsVC = storyboard.instantiateViewController(withIdentifier: "ClientDebts") as! ClientDebtViewController
    clientDebtsVC.client = self.client
    controller.orderedViewControllers = [clientInfoVC,clientRequestsVC,clientDebtsVC]
    controller.view.frame = CGRect(x: 0, y: 0, width: self.clientContainerView.frame.width, height: self.clientContainerView.frame.height)
    self.clientContainerView.addSubview(controller.view)
    controller.didMove(toParentViewController: self)

这是我的容器视图:

视图控制器

我究竟做错了什么?请帮我

4

1 回答 1

0

我找到了解决方案:

我需要删除控制器的框架设置,仅此而已。所以只需删除这一行:

    controller.view.frame = CGRect(x: 0, y: 0, width: self.clientContainerView.frame.width, 
                                             height: self.clientContainerView.frame.height)
于 2017-08-03T18:47:02.883 回答