来自 xib 的 addSubview - iOS 8 对比 iOS 9

addSubview from xib - iOS 8 vs iOS 9

这是我要添加的 viewController(视图在 .Xib 文件中)

class EmptyFeedViewController: UIViewController {
   @IBOutlet weak var view_center: UIView!
   @IBOutlet weak var img_icon: UIImageView!
   @IBOutlet weak var lbl_description: UILabel!

   override func viewDidLoad() {
      super.viewDidLoad()
      view.backgroundColor = UIColor.grayPale()
      lbl_description.textColor = UIColor.grayMeduim()
      lbl_description.text = "feed_empty".localizeFromFeedTable()
   }

   override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
   }
}

我从另一个viewController

这样添加的
let placeholderVC = EmptyFeedViewController()
addChildViewController(placeholderVC)
view_placeholder = placeholderVC.view

在 iOS 9 上工作正常,但在 iOS 8 上 "lbl_description" 为零 我应该如何为 OS 加载我的视图?

由于您使用的是 Xibs,为了填充 IBOutlets,您应该使用指定的初始化程序 - initWithNibName:bundle:

创建视图控制器的新实例
let placeholderVC = EmptyFeedViewController(nibName: "EmptyFeedViewController",
                                             bundle: nil)