使用以下代码创建视图.
- (void)loadView { paintView=[[UIView alloc]initWithFrame:CGRectMake(0,50,320,430)]; [paintView setBackgroundColor:[UIColor yellowColor]]; self.view = paintView; [paintView release];
但我的问题是整个屏幕填充黄色,但我想要指定的框架.
我在基于视图的应用程序中创建此视图..我做错了什么,Overridind原始视图?
解决方法
你可以通过以下方式完成.
- (void)loadView { /// make a empty view to self.view /// after calling [super loadView],self.view won't be nil anymore. [super loadView]; paintView=[[UIView alloc]initWithFrame:CGRectMake(0,430)]; [paintView setBackgroundColor:[UIColor yellowColor]]; [self.view addSubview:paintView]; [paintView release]; };