self.view.subviews 空 iOS 8

self.view.subviews empty in iOS 8

我用 xib 创建了自定义 UIViewController,现在我想从中获取第一个子视图...它适用于 iOS 9,但在 iOS 8 view.subviews 上有 0 个视图

let customVC = CustomViewController()
 
var customTestView = customVC.view.subviews.first

self.view 应该有 1 个子视图

如果您使用 xib 创建 ViewController,您应该使用它来初始化 ViewController

let vc =  CustomViewController(nibName: "nib", bundle: NSBundle.mainBundle())