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..

enter image description here

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:

  1. you should have advancedcellview set file's owner custom class in identity inspector.
  2. check module correct - want blank.
  3. the custom class view should not set, leave default (uiview). if have more descriptive name 'view' in sidebar, it's wrong.
  4. check have 1 top level object in nib. sidebar should this, without other entries, when have view tree collapsed.

nib hierarchy 1 top level view

n.b. answer related tutorial op linked to, , not correct way set nib.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -