I'm trying to make a subclass of the UIBarButtonItem
class. The button is added in the nib file and I set its class to my custom class in the interface builder. Now if this was a UIView
class or subclass I would have override the - (id)initWithCoder:(NSCoder *)decoder
method to start the extra customization, however UIBarButtonItem
lacks开发者_StackOverflow such a method. I tried to override its -(id)init
method but with no success, it doesn't get called. My question, where should I start my customization? What method do I need to override?
It's because you use IB. When you create an object in IB it does not call the init method for the class, it uses the archive version of the object. So to make custom initializations use this method instead:
-(void)awakeFromNib{
//initialize here
}
精彩评论