Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-18-2009, 02:30 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 17
parsa28 is on a distinguished road
Question Subclassing UIButton

Hello there, I need a custom button so I made a subclass of UIButton with custom settings in the "-init" method. But since I'm going to need many instances of this class, I'd rather not alloc,init them using code, but using IB.

But after setting the button classes to my own subclass in IB, their look simply doesn't change and thats obvious since it has not been initialized.

Whats the solution to this ? Thanks for your time.
parsa28 is offline   Reply With Quote
Old 03-18-2009, 02:32 PM   #2 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

Objects that are rehydrated from nibs get their initWithCoder method called, not other init methods.
PhoneyDeveloper is offline   Reply With Quote
Old 03-18-2009, 02:42 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 17
parsa28 is on a distinguished road
Default SOLVED

Thanks a lot for your quick and correct help.
parsa28 is offline   Reply With Quote
Old 03-18-2009, 04:18 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 17
parsa28 is on a distinguished road
Default

Update: by reading around the web, I got that if the purpose is just doing post NIB loading instantiation, -(void)awakeFromNib could be a better choice.

Regards,
Parsa
parsa28 is offline   Reply With Quote
Old 03-18-2009, 05:06 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Kyiv, Ukraine
Posts: 56
PoweredFlight is on a distinguished road
Default

You might be really better off writing your own Button class based on UIView or UIControl. Subclassing UIButton may hurt you sooner or later.
__________________
CashTrails (and Lite) - Fast and flexible income and expense tracker for iPhone and iPod touch. (website)
iAnonymize (and FREE) - Hide private photo parts right on your iPhone. (website)
PoweredFlight is offline   Reply With Quote
Old 03-19-2009, 03:59 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 17
parsa28 is on a distinguished road
Default

Quote:
Originally Posted by PoweredFlight View Post
You might be really better off writing your own Button class based on UIView or UIControl. Subclassing UIButton may hurt you sooner or later.
why do you say so ?
parsa28 is offline   Reply With Quote
Old 03-20-2009, 06:22 AM   #7 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Kyiv, Ukraine
Posts: 56
PoweredFlight is on a distinguished road
Default

Quote:
Originally Posted by parsa28 View Post
why do you say so ?
Because when you create a button, an instance of UIPushButton or the like is actually created, depending on the supplied button type, and you would have hard time overriding methods in your own subclass for, say, custom event handling.
__________________
CashTrails (and Lite) - Fast and flexible income and expense tracker for iPhone and iPod touch. (website)
iAnonymize (and FREE) - Hide private photo parts right on your iPhone. (website)
PoweredFlight is offline   Reply With Quote
Reply

Bookmarks

Tags
button, custom, interface builder, uibutton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 336
3 members and 333 guests
guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0