本文介绍了IB Designables:无法呈现和更新自动布局状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义视图( xib
)里面有一个 UIButton
,我做了一个id IBDesignable
执行以下操作:
I have a custom view (xib
) that has a UIButton
inside of it, I made id IBDesignable
doing the following:
UserView.swift
import UIKit
@IBDesignable
class UserView: UIView {
@IBOutlet var view: UIView!
@IBOutlet weak var userButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
load()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
load()
}
fileprivate func load() {
Bundle.main.loadNibNamed("UserView", owner: self, options: nil)
addSubview(view)
self.frame = bounds
}
}
UserView.xib
- 添加了UIButton并设置了约束
- 设置文件所有者:
UserView
- Added the UIButton and set constraints
- Set the File's Owner:
UserView
我在 Bar Button Item 并分配了UserView类,但没有渲染,我得到以下构建错误:
I added a UIView to a Bar Button Item
and assigned UserView class but nothing is rendering, and I got the following build error:
我目前的环境: Xcode 9 ,Swift 4
My currently environment: Xcode 9, Swift 4
推荐答案
我在 Podfile
的末尾添加此脚本并执行<$ c再次$ c> pod install 。所以我可以正常构建我的项目。
I add this script at the end of my Podfile
and performed pod install
again. So I could build normally my project.
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
这篇关于IB Designables:无法呈现和更新自动布局状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!