Interface Builder doesn't call Init?

Discussion in 'iOS Programming' started by ArtOfWarfare, Sep 4, 2011.

  1. ArtOfWarfare macrumors G3


    Nov 26, 2007
    I made a custom class that is a subclass of UIView and added it by adding a UIView in my xib file then changing its class to my custom class.

    My custom class isn't being told initWithFrame:(CGRect)frame at any time, as the set up code I have in there isn't being called. Is there some other method I should use that will automatically be called when the xib is opened or should I just make my own set up method that my view controller calls?
  2. hayesk macrumors 65816

    May 20, 2003
    When you add an existing class to a xib and change the class to your subclass, it calls initWithCoder, not initWithFrame. Implement that method and you should be fine.

Share This Page