initwithstyle:reuseIdentifier: not called

I’m creating my own custom UITableViewCell to use as the backend of a prototype cell. In my class I override the initwithstyle:reuseIdentifier: method to do some custom initialization, but my initializer is not called. I have a break point on the first line inside of it, as well as a break point on dequeueResusableCellWithIdentifier:. The dequeueResusableCellWithIdentifier: method is called, and it returns a initilized cell, but the break point in initwithstyle:reuseIdentifier: is not reached. Any help would be great.

  • Swift frameworks do not work with build configurations named other than 'Debug' or 'Release': No such module
  • dismissViewControllerAnimated VS popViewControllerAnimated
  • NSMutableArray alloc init vs NSMutableArray array
  • ios8 UIModalTransitionStylePartialCurl doesn't work properly
  • 2 UITableViews in one UIView
  • How can you show the debugger console in “xcode 6”
  • 3 Solutions Collect From Internet About “initwithstyle:reuseIdentifier: not called”

    If your cell is being created from a storyboard prototype (which you have declared as the custom class in IB) then it won’t be created with initWithStyle... but initWithCoder: instead, like any other object loaded from a nib. If you have any setup code, it should be in there or in awakeFromNib.

    With the storyboard involved, everything changes. This is the method that gets called.

    -(id)initWithCoder:(NSCoder *)aDecoder {
        if ( !(self = [super initWithCoder:aDecoder]) ) return nil;
    
        // Your code goes here!
    
        return self;
    }
    

    If you are using StoryBoarsd then UITableViewContoller won’t call initWithStyle replace it with initWithCoder it will works now