子视图控制器的表视图中的最后一行无法选择

时间:2017-08-03 16:33:38

标签: ios uiviewcontroller childviews

我正在尝试使用表视图创建一个视图容器。这样可以正常工作,但如果我选择最后一行,则无法触发方法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)

这是我的容器视图:

viewcontroller

我做错了什么? 请帮帮我

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

我需要删除控制器的帧设置,就是这样。所以只需删除这一行:

    controller.view.frame = CGRect(x: 0, y: 0, width: self.clientContainerView.frame.width, 
                                             height: self.clientContainerView.frame.height)