容器视图不会在滚动中检查UITableView数据?

时间:2018-05-17 11:51:22

标签: ios swift uitableview swift4 uicontainerview

我已经以编程方式创建了一个带有子ViewControllers的容器视图。子视图包含UITableView但我无法滚动UITableView(如果我从UITableView滚动数据隐藏)。

let VC = self.storyboard?.instantiateViewController(withIdentifier: "roomList") as! roomListViewController
VC.view.frame = CGRect(x: 0, y: 0, width: (containerView?.frame.size.width)!, height: (containerView?.frame.size.height)!)
  ///  self.containerView?.isHidden = false
  self.containerView?.addSubview(VC.view)
  let flipDirection: UIViewAnimationOptions = flipped ? .transitionFlipFromTop : .transitionFlipFromBottom
  let options: UIViewAnimationOptions = [flipDirection, .showHideTransitionViews]
  UIView.transition(from: VC.view, to: VC.view, duration: 0.6, options: options) {
        finished in

    }

1 个答案:

答案 0 :(得分:0)

我修复了addChildViewController(VC)和VC.didMove(toParentViewController:self)父方法。我的工作代码是

        let VC = self.storyboard?.instantiateViewController(withIdentifier: "roomList") as! roomListViewController
        addChildViewController(VC)
        VC.view.frame = CGRect(x: 0, y: 0, width: (containerView?.frame.size.width)!, height: (containerView?.frame.size.height)!)
        VC.delegate = self

        self.containerView?.addSubview(VC.view)
        //controller.didMoveToParentViewController(self)
        VC.didMove(toParentViewController: self)
        let flipDirection: UIViewAnimationOptions = flipped ? .transitionFlipFromTop : .transitionFlipFromBottom
        let options: UIViewAnimationOptions = [flipDirection, .showHideTransitionViews]
        UIView.transition(from: VC.view, to: VC.view, duration: 0.6, options: options) {
            finished in

            //cardModel.flipped = !flipped
        }