iosuiviewcontrollerchildviews

Last row on child view controller's table view cannot select


I'm trying to make a view container with table view. That's works fine, but if i select the last row, the method didSelectRowAt indexPath: cannot be triggered. This is my code:

    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)

And this is my container view:

viewcontroller

What am I doing wrong? Please help me


Solution

  • I found the solution:

    I needed to remove the controller's frame setting and thats it. So Just remove this line:

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