Search code examples
iphoneobjective-ccocoa-touchiosloadview

How to implement loadView?


I've created a custom view called GraphView. All I get is a blank black screen when the view is loaded. Here is my code:

in GraphViewController.m:

@synthesize graphView, graphModel;

- (void)loadView
{   
    GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectZero];
    self.view = aGraphView;
    self.graphView = aGraphView;

    [aGraphView release];
}

I'm not sure why I just get a black screen when I try to implement loadView in GraphViewController.m


Solution

  • I need to make the background color white in loadView

    - (void)loadView
    {   
        GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectZero];
        aGraphView.backgroundColor = [UIColor whiteColor];
        self.view = aGraphView;
        self.graphView = aGraphView;
    
        [aGraphView release];
    }