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: Roland King <email@hidden>
- Date: Wed, 15 Feb 2012 10:27:23 +0800
On 15 Feb, 2012, at 8:48, William Squires <email@hidden>
> AppDelegate loads the view controller and it's xib - confirmed, as the drawRect: method in TestView does its thing (ViewController.xib's view's class is set to TestView). But when I put an NSLog in TestView.m by adding a -(void)viewDidLoad(), it never fires, and neither does the -initWithFrame: method. So what's the correct place to put initialization code for a custom UIView subclass?
UIView doesn't have a viewDidLoad() method so your NSLog wouldn't fire.
UIView subclasses instantiated from NIBs have their initWithCoder: method called. That's documented in the NIB Object Life-Cycle documentation. I usually write one initialization method and call it from initWithFrame: and initWithCoder:
Or use awakeFromNib.
> Or is my installation of Xcode screwed up?
>
Probably not. Why would you think that.
_______________________________________________
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