1

I am doing this to move a ViewController(viewController) to other ViewController(mainMenuViewController) :

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "subView")
    addChildViewController(controller)
    view.addSubview(controller.view)
    controller.view.frame.size.width = 375
    controller.view.frame.size.height = 198
    controller.didMove(toParentViewController: self)

viewController get moved to mainMenuViewController but problem is that I can't see the the other items like tableView, button I have added to mainMenuViewController

Usman Qamar
  • 49
  • 1
  • 9
  • Possible duplicate of [How do I change UIView Size?](https://stackoverflow.com/questions/26706565/how-do-i-change-uiview-size) – Rakesha Shastri Jan 02 '19 at 05:09
  • "but problem is that I can't see the the other items like tableView, button I have added to mainMenuViewController" So presumably you are putting `controller.view` in a place that covers them. If you don't want that, don't do that. What's the question? – matt Jan 02 '19 at 06:25

1 Answers1

0

Set frame instead of just height

controller.view.frame = CGRect(x: xPosition, y: y, width: width, height: height)

Also set autoreszingmaskToconstraint to false

controller.view.translatesAutoresizingMaskIntoConstraints = false;
Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88