swift的xib在模拟器显示正常,真机不显示

Jan 8, 2017

发表于(2016-06-13 11:34:52)

这个完美解决了swift会不加载xib的问题~~xib都OK,模拟器可以显示,但是真机却没有显示的解决方案,原因就是swift不默认加载xib,强制让他加上就好了
http://my.oschina.net/227/blog/470553
这个是转帖嘿嘿,谢谢大哥啦

import UIKit
class FormController: UIViewController {

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//println(nibName); }
convenience init() {
var nibNameOrNil = String?(“FormController”)

// //考虑到xib文件可能不存在或被删,故加入判断// if NSBundle.mainBundle().pathForResource(nibNameOrNil, ofType: “xib”) == nil{ nibNameOrNil = nil}
self.init(nibName: nibNameOrNil, bundle: nil)
}
required init(coder aDecoder: NSCoder) {
fatalError(“init(coder:) has not been implemented”)
}

override func viewDidLoad() {

}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated. }

}