ios - UIviewcontroller - what time is the view property instantiated? -



ios - UIviewcontroller - what time is the view property instantiated? -

i'm wondering time exactely created .view property of uiviewcontroller.

i created viewcontroller, , in init(coder: adecoder) started set few variables. when tried set viewcontroller.view.backgroundcolor crashed. placed same line of code within viewdidload , worked.

this code

class webviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() println("didload") self.view.backgroundcolor = uicolor.redcolor() } required init(coder adecoder: nscoder) { println("init coder") super.init(coder: adecoder) self.tabbaritem.title = nil //self.view.backgroundcolor = uicolor.redcolor() // cause crash } }

this error :

terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'could not load nib in bundle: 'nsbundle </users/mari/library/developer/coresimulator/devices/a9cc10d9-409e-4604-a6f7-b3729e0b3d52/data/containers/bundle/application/f5dfdfe6-87b9-40af-a26b-7b5a1506d203/test.app> (loaded)' name '9pv-a4-qxb-view-tsr-hk-won''

during init coder vc instantiated, tab bar can set cause it's root view controller ( tab bar controller ), view property of vc during init, still not ready set up. right?

so... when view property exactely instantiated? when best moment set ?

the view instantiated between initializer (in case init(coder adecoder: nscoder)) , viewdidload.

within period, ios loads ui components ib files. developer have possibility customize view (e.g. changing colors) in viewdidload.

you can read more in documentation view controller lifecycle.

ios objective-c uiviewcontroller

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -