override public func loadView() {
NSBundle.mainBundle().loadNibNamed("DatePickerDialog", owner: self, options: nil)
}
This code is the usual way of linking a ViewController to its interface builder. However, once I moved these kinds of files to a framework, and make a call to it, it crashes. I know that I can override an init and specify the bundle ID but it won't pre-load the UI and will result from UI elements not initialized.
Instead of calling NSBundle.mainBundle()
, call either NSBundle(identifier: String)
or NSBundle(forClass: AnyClass)
. The former takes an NSString argument of the framework's indentifier; the latter takes a Class argument of a class provided by the framework.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.