How to subclass UIButton?
How to subclass UIButton?
- Subject: How to subclass UIButton?
- From: WT <email@hidden>
- Date: Wed, 7 Apr 2010 23:26:43 +0200
Hello all,
I need to create a custom bar of UIButton instances which can be scrolled left and right using a swipe gesture. I am thus following the "Autoscroll" sample code from Apple, which subclasses UIImageView to produce a scrollable bar of thumbnail images. My problem is how to correctly subclass UIButton, since the only available means of instantiating a button is through the class method +buttonWithType:.
Once I allocate an instance of the subclass, how do I initialize it with the desired type? The buttonType property is read-only and there is no instance method -initWithType: in the public API.
One alternative I see is to use composition rather than subclassing, essentially creating a decorator for UIButton, but I'd rather not have to do that.
Another option is to fake a button using UIImageView, just like the "Autoscroll" example does, but I'd prefer to have actual UIButton instances.
Am I missing something trivial here? If UIButton was designed in such a way to prevent subclassing, what would you suggest as the best alternative?
Thanks in advance.
WT._______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden