• 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: Custom UIView drawing but can't figure out when/where it's loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Sandbox - Security Scoped URLs (10.7.3)
  • Next by Date: Re: Sandbox - Security Scoped URLs (10.7.3)
  • Previous by thread: Re: Custom UIView drawing but can't figure out when/where it's loading
  • Next by thread: Re: NSEvent locationInWindow undefined for non-mouse events, how to catch?
  • Index(es):
    • Date
    • Thread