ios - Instantiate view from nib throws error -
i tried make @ibdesignable uiview subclass following (link) tutorial. first custom view goes fine. when try make one, have errors. first got failed update auto layout status: agent crashed
, failed render instance of ...
. somehow started able biuld , run project these errors, new error - exc_bad_access ...
on line let view = nib.instantiatewithowner(self, options: nil)[0] as! uiview
. here whole method:
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 }
with first custom uiview no problem. use same code..
any ideas? thank you
the loadviewfromnib()
method post looks fine, you're getting bundle correctly , specifying nib name string literal, should find nib. else commented, there's wrong set of nib instead. here few things check:
- you should have
advancedcellview
set file's owner custom class in identity inspector. - check module correct - want blank.
- the custom class view should not set, leave default (uiview). if have more descriptive name 'view' in sidebar, it's wrong.
- check have 1 top level object in nib. sidebar should this, without other entries, when have view tree collapsed.
n.b. answer related tutorial op linked to, , not correct way set nib.
Comments
Post a Comment