Reputation: 1371
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
Upvotes: 4
Views: 5520
Reputation: 1371
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];
}
Upvotes: 2
Reputation: 18122
You're not setting a frame for the GraphView
object:
GraphView *aGraphView = [[GraphView alloc] init];
The designated initializer for UIView
's is -initWithFrame:
. Do something like this (setting the size/origin of the view as you desire):
GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
Upvotes: 2