Re: Custom UIView drawing but can't figure out when/where it's loading
Re: Custom UIView drawing but can't figure out when/where it's loading
- Subject: Re: Custom UIView drawing but can't figure out when/where it's loading
- From: Matt Neuburg <email@hidden>
- Date: Wed, 15 Feb 2012 06:43:21 -0800
On Tue, 14 Feb 2012 18:48:10 -0600, William Squires <email@hidden> said:
>So what's the correct place to put initialization code for a custom UIView subclass?
Depends how it's instantiated. If in code, initWithFrame. But if from a nib, initWithFrame will never be called; instead, use initWithCoder or awakeFromNib:
http://www.apeth.com/iOSBook/ch07.html#_additional_initialization_of_nib_based_instances
It very often happens that I'll encapsulate the additional initialization in a single method and call that from initWithFrame *and* initWithCoder, so that it won't matter which way the view was instantiated. m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
_______________________________________________
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