I'm trying to create the perfect solution to make a custom UIView
subclass directly from code and in Storyboard
. However, I didn't found any solution.
For an IBDesignable
solution through storyboard, I followed this example http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6 and works perfectly.
But if I try to call this subclass through UIViewController
by calling this Extension method:
extension UIView {
class func loadFromNibNamed(nibNamed: String, bundle : NSBundle? = nil) -> UIView? {
return UINib(
nibName: nibNamed,
bundle: bundle
).instantiateWithOwner(nil, options: nil)[0] as? UIView
}
}
It crashes and says that misses this class is not key value coding-compliant for the key
.
Has anybody found a solution to share with me for have both possibilities?
I need it because I should use this UIView
in storyboard and also as UITableview SectionHeader