Loading Xib on UIView causing all the other components inside UIViewController hide

135 views Asked by At

Informations : I am trying to swap two .xib which will be inside UIView of my StepsUIViewController class. And I set their file owner name as my StepsUIViewController because I want to do their procedures inside that view controller and that is the important thing at this topic.

Requirement :

My requirement is changing the two xib base on each situation. So, since I set their file owner name as StepsUIViewController, implementation of both xib will be done inside StepsUIViewController.

And I am going to present that StepsUIViewController modally. So there will be no UINavigationBar until I drag and drop from tools.

Here is my view hierachy :

enter image description here

And here is my StepsUIViewController :

enter image description here

So inside Step1View, I will change the two xib I created base on push(UIButton) action. Now here comes the problem. When I load those xib, UINavigationBar didn't appear as well as push button also disappear and instead that xib(UIView) cover the whole StepsUIViewController.

Here is my code :

import UIKit


class StepsViewController: UIViewController{

@IBOutlet weak var step1View : UIView!

     override func loadView() {
          super.loadView()
          let someView = NSBundle.mainBundle().loadNibNamed("StepsInfo", owner: self, options:nil)[0]
          step1View = someView as! UIView
     }
}

Here what I am facing :

enter image description here

What am I doing wrong? I am new to xib and all my life dropping UIComponents to UIViewController inside storyboard and I am thinking to change it and create view dynamically on single UIViewController. Any Help?

0

There are 0 answers