我试图制作一个@IBDesignable的UIView子类,按照这个(链接)教程进行。第一个自定义视图没问题。但是当我尝试制作另一个视图时,遇到错误。首先我得到了failed to update auto layout status: the agent crashed
和Failed to render instance of ...
。不知何故,我开始能够使用这些错误来构建和运行项目,但然后我遇到了新的错误-EXC_BAD_ACCESS
在let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
行。下面是整个方法:
func loadViewFromNib() -> UIView {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: "advancedCellView", bundle: bundle)
let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
return view
}
使用第一个自定义的UIView没有问题。我使用相同的代码..
有任何想法吗?谢谢
NSBundle:forClass:
而不是直接访问NSBundle.mainBundle()
呢?这个nib
存储在一个不同的bundle中吗? - Aaron Rasmussen