2016-09-20 71 views
-1

我正在使用带有自定义XIB的Storyboard,在升级到swift 2和xcode 7之前,所有内容都会正常加载。升级完成后,可以将故事板转换为xcode 8.我的viewcontroller显示视图,但它缺少我的自定义XIB。看看故事板文件,它看起来像一个故事板与自定义XIB转换的错误。还有谁有相同的问题吗?用Swift 3加载时自定义XIB缺失3 Xcode 8

required public init(coder aDecoder: NSCoder) { 
    super.init(coder: aDecoder)! 
    let bundle = Bundle(for: type(of: self)) 
    let nib = UINib(nibName: self.dynamicTypeName, bundle: bundle) 
    let nibView = nib.instantiate(withOwner: self, options: nil).first as! UIView 
    self.mainView = nibView 
    self.mainView.frame = bounds 
    self.mainView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 
    mainView.translatesAutoresizingMaskIntoConstraints = true 
    self.addSubview(mainView) 
} 

回答

0

出了点与SWIFT 3的布局过程中,因为升级

之前调用self.mainView.frame =界限,会给你正确的范围,但现在随着SWIFT 3的总( 0,0,1000,1000),所以我必须在layoutSubviews中设置框架以获得正确的边界。

open override func layoutSubviews() { 
    self.mainView.frame = bounds 
} 
+0

我也面临同样的问题,你有没有找到任何解决方案。 –

+0

是的,尝试在layoutSubviews – RiceAndBytes

+0

中设置您的自定义xib框架不知道为什么它不自动拍摄框架,尽管提供的房间仍然是全屏幕(比如mainscreen.rect) –

相关问题