自从迁移到Swift 3以获取以下代码:
func setup() {
Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?[0] as! UIView
self.addSubview(customView)
customView.frame = self.bounds
}
Run Code Online (Sandbox Code Playgroud)
我现在收到警告:Expression of type 'UIView' is unused.我在这做错了什么?
您从未声明并设置customView,这就是编译器抱怨不使用结果的原因loadNibNamed.
let customView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?[0] as! UIView
| 归档时间: |
|
| 查看次数: |
4959 次 |
| 最近记录: |