Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"-(id) init" do not fire in ViewController when using storyboard

Tags:

ios

I notice "-(id) init" in ViewController is not executed when using storyboard. is there any other method that could replace init, or is there is away to force firing init.

like image 815
user836026 Avatar asked Feb 09 '12 18:02

user836026


2 Answers

try to use

- (id)initWithCoder:(NSCoder*)aDecoder 
{
    if(self = [super initWithCoder:aDecoder]) 
 {
        // Do something
    }
    return self;
}
like image 192
NeverBe Avatar answered Oct 06 '22 00:10

NeverBe


- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle is called instead.

As the comment above indicates, you need to decide if there might be a more appropriate method to override. Keep in mind that the view has not yet been loaded in the initWithNibName method, so don't try to change anything there yet.

like image 45
picciano Avatar answered Oct 05 '22 23:10

picciano