我无法弄清楚为什么这个视图占据了整个屏幕。UIView的大小不像预期的那样是
在AppDelegate的文件
...
self.viewController = [[[ViewController alloc]init]autorelease];
[self.window setRootViewController:self.viewController];
self.window.backgroundColor = [UIColor whiteColor];
..
在ViewController.m
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(30, 30, 30, 30)];
[view setBackgroundColor:[UIColor greenColor]];
self.view = view;
当我运行应用程序的屏幕完全是绿色的,而不是只有一个绿色的正方形。 这里有什么问题?
您在哪里设置'self.view = view'? – 2012-02-18 14:22:51
我不明白你问什么。 – OhDoh 2012-02-18 14:28:37
你在哪里第二段代码?在'loadView'方法中?但正如Richard J. Ross III所建议的,也许你需要使用(例如)'[self.window addSubview:view];' – 2012-02-18 14:33:20