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: Luke Hiesterman <email@hidden>
- Date: Wed, 15 Feb 2012 02:13:03 +0000
- Thread-topic: Custom UIView drawing but can't figure out when/where it's loading
-viewDidLoad is a method on UIViewController - it's not something that will get called on a UIView. If you have initialization code, you should override the default initializer, -initWithFrame:.
Understanding the role of view controllers and views is an important thing to have as a foundation for iOS programming. I would suggest reading
https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html
and
https://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
Luke
On Feb 14, 2012, at 4:48 PM, William Squires wrote:
> In my sample project, I've got
>
> TestView.h
> TestView.m
> RBTestView.h
> RBTestView.m
> AppDelegate.h
> AppDelegate.m
> ViewController.h
> ViewController.m
> ViewController.xib
>
> 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? Or is my installation of Xcode screwed up? An NSLog() placed in ViewController.m in it's viewDidLoad method does fire, which is what I would expect. What stupid little thing am I missing here?
>
> I've also got these files:
>
> UIRBView.h // #imports Graphics.h and Polygon.h
> UIRBView.m
> Graphics.h
> Graphics.m
> Polygon.h
> Polygon.m
>
> UIRBView is the implementation of a custom UIView subclass (also), but it is supposed to create an instance of a Graphics object which is a handy wrapper class I wrote to make handling drawing in a view more like REALbasic. But if I can't get TestView to confirm that it's loading, I don't have a chance of confirming that my UIRBView subclass (RBTestView.h and RBTestView.m) are loading. Help!
>
> RBTestView inherits from UIRBView which inherits from UIView, and TestView inherits from UIView.
>
> When I set the view (in ViewController.xib) to RBTestView instead of TestView, it doesn't crash, but just displays the screen filled with light gray.
>
> FWIW, this is an iOS 5 project with ARC turned on.
>
>
> _______________________________________________
>
> 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