0

I am trying to add a UIViewController XIB to an existing ViewController, trying to create this:

enter image description here

I have a simple ViewController and then I made a UIView with XIB... and now I am trying to use it in the new ViewController:

    let myVC = XIBViewController(nibName: "XIBViewController.xib", bundle: nil)
    self.present(myVC, animated: true, completion: nil)

How can I make it as small as in the image, with the BaseViewController still visible?

Habin Lama
  • 529
  • 5
  • 19

1 Answers1

1

Replace ( Remove .xib )

let myVC = P3XIBViewController(nibName: "P3XIBViewController.xib", bundle: nil)

with

let myVC = P3XIBViewController(nibName: "P3XIBViewController", bundle: nil)
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • The view still does not show up, I get this: Warning: Attempt to present on whose view is not in the window hierarchy! –  Apr 28 '19 at 20:24
  • Don't present it inside `viewDidLoad` as it's too early – Shehata Gamal Apr 28 '19 at 20:25
  • Ok, it worked now... but how can I make it as small as in the image in my question? –  Apr 28 '19 at 20:44