How to use XIB in an iOS Swift project

I had two separate Xcode projects that I put into one: speech recognition of text, which is implemented using an XIB file written in Objective-C, and another project, which is a regular user interface written in Swift, is something else. Both projects work flawlessly on their own. I cleared all the errors and created the Bridging header file. Swift and Objective-C modules still coexist, but obviously only a part of Swift works. I want to open XIB Objective-C and display it in my fast coding user interface.

Project structure

+4
source share
1 answer

, , Swift.

XIB , . loadNibNamed, :

var nibs = NSBundle.mainBundle().loadNibNamed("Counter", owner: self, options: nil)
for v in nibs {
    if (v is Counter) {
       someViewInStoryboard.addSubview(v)
   }
}

Counter.xib, UIView. Counter, UIView.

, XIB , , , UIView . someViewInStoryboard - IBOutlet UIView.

0

All Articles