[英]UIViewController: set self.view to my view or add my view as subview?
[英]load subview over self.view
我正在尝试在当前视图上添加UIView,但是没有运气。我确定我的代码正确,但是不确定要检查什么,插入子视图时还应该考虑什么?
这就是我添加到viewDidLoad中的内容
//..
cellContainer = [[UIView alloc] init];
cellContainer.frame = CGRectMake(0.0, 480.0, 320.0, 300.0);
[self.view addSubview:cellContainer];
self.view.backgroundColor = [UIColor greenColor];
//..
cellContainer在标头中声明为UIView ...任何帮助,将不胜感激。
cellContainer
可能已添加到UIViewController
的视图层次结构中,但是您已将框架设置为不在屏幕上。 尝试这个:
cellContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
[self.view addSubview:cellContainer];
self.view.backgroundColor = [UIColor greenColor];
这将在视图的左上方显示cellContainer
,在右x方向上延伸320px,在下y方向上延伸300px。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.