Changing UIView's xib file and file owners code on UISegmented controller switch

460 views Asked by At

I am a highschool student and I am working on an application for world war one soldiers. Anyways, there is a UIView that contains a UISegemented Controller that when the users interacts will change a UIView Below.

So, an Overall UIView that contains a UIView and a segmented controller to change the contents of that smaller UIView.

I have it so that on the switch of the Segmented Controller does this

 switch value {
        case 0 : NSBundle.mainBundle().loadNibNamed("Profile", owner: self, options: nil)
        case 1 : NSBundle.mainBundle().loadNibNamed("Regiment", owner: self, options: nil)
        case 2 : NSBundle.mainBundle().loadNibNamed("Mapping", owner: self, options: nil)
}

The problem with this is that it just loads the .xib file and not their code. Their connections/events don't work and crash the program because it won't connect to their .swift file that is their file owner.

enter image description here

How do I programmatically set .xib corresponding .swift file.

I was hoping there would be something like this in xCode.

UIView.setParentCustomClass(class.swift) //Psuedo 
0

There are 0 answers