• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to subclass UIButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to subclass UIButton?


  • Subject: Re: How to subclass UIButton?
  • From: john chen <email@hidden>
  • Date: Wed, 7 Apr 2010 21:44:00 -0700

I think UIButton is not designed for subclassing. You can try
composition, or create UIButton category method for custom-build
button. Apple has sample code in UICatalog to create custom-build
button.

On Wed, Apr 7, 2010 at 2:26 PM, WT <email@hidden> wrote:
> 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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: How to subclass UIButton?
      • From: WT <email@hidden>
References: 
 >How to subclass UIButton? (From: WT <email@hidden>)

  • Prev by Date: re: Problem with vCard and AddressBook ABPerson UID, HELP!!
  • Next by Date: Re: Problem with vCard and AddressBook ABPerson UID, HELP!!
  • Previous by thread: How to subclass UIButton?
  • Next by thread: Re: How to subclass UIButton?
  • Index(es):
    • Date
    • Thread