I've successfully subclassed UIButton with no problems. I my case I wasn't interested in the "style" since I was implementing my own, so I created my own class method which just calls initWithFrame:
+ (id)buttonWithFrame:(CGRect)frame { return [[[self alloc] initWithFrame:frame] autorelease]; } - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // do my additional initialization here } return self; } Note that this way the buttonType isn't explicitly set to anything, which probably means that it's UIButtonTypeCustom. The Docs don't seem to actually specify that, but since that's the 0 value in the enum, that's likely what happens (and that seems to be the observable behavior as well) If you want to use the existing buttonWithStyle: method, all you need to do is implement initWithFrame:, since that's the default initializer, then call [MyButton buttonWithStyle:whatever] and you're done! If you also want to be able to use your subclass in .xib files, then you'll also need to implement initWithCoder: (calling the super implementation) and put your initialization code in there as well. -- // jack // http://nuthole.com // http://learncocoa.org _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com