4

我创建了一个名为GraphView. 加载视图时,我得到的只是一个空白的黑屏。这是我的代码:

在 GraphViewController.m 中:

@synthesize graphView, graphModel;

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

    [aGraphView release];
}

我不知道为什么我在尝试实施时会出现loadView黑屏GraphViewController.m

4

2 回答 2

2

您没有为GraphView对象设置框架:

GraphView *aGraphView = [[GraphView alloc] init];

UIView's的指定初始化程序是-initWithFrame:. 做这样的事情(根据需要设置视图的大小/原点):

GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];

于 2011-03-14T02:08:54.327 回答
2

我需要将背景颜色设为白色loadView

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

    [aGraphView release];
}
于 2011-03-18T18:17:51.620 回答