本文介绍了如何实现loadView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个名为 GraphView
的自定义视图。所有我得到的是一个空白的黑屏,当视图加载。这是我的代码:
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:
在GraphViewController.m:
in GraphViewController.m:
@synthesize graphView, graphModel;
- (void)loadView
{
GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectZero];
self.view = aGraphView;
self.graphView = aGraphView;
[aGraphView release];
}
我不知道为什么我只是得到一个黑色的屏幕,在中实现
loadView
I'm not sure why I just get a black screen when I try to implement loadView
in GraphViewController.m
推荐答案
我需要使 loadView中的背景颜色为白色
- (void)loadView
{
GraphView *aGraphView = [[GraphView alloc] initWithFrame:CGRectZero];
aGraphView.backgroundColor = [UIColor whiteColor];
self.view = aGraphView;
self.graphView = aGraphView;
[aGraphView release];
}
这篇关于如何实现loadView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!