我正在试验一个包含的视图控制器,但即使是最简单的形式也有问题。基本上,它切断了底部的 90 个像素,我不知道为什么。
我已经包含了我的代码和一个屏幕截图,旁边有一个类似大小的 UIView。这 90 像素clipping
在不同大小上是一致的(即,如果将高度设为 200 像素,则显示为 110 像素)。任何帮助将不胜感激,因为这变得非常令人沮丧。为什么它的尺寸是这个尺寸,我该如何解决?
提前谢谢
- (void)viewDidLoad
{
// this is the left one below that is the problem
[super viewDidLoad];
self.myView=[[JtViewController alloc] initWithNibName:@"JtViewController" bundle:nil];
self.myView.view.frame=CGRectMake(10.0f,10.0f,100.0f,100.0f);
self.myView.view.backgroundColor=[UIColor orangeColor];
[self addChildViewController:self.myView]; // 1
[self.view addSubview:self.myView.view];
[self.myView didMoveToParentViewController:self.myView]; // 3
// this one is ok
self.testView=[[UIView alloc] init];
self.testView.frame=CGRectMake(150.0f,10.0f,100.0f,100.0f);
self.testView.backgroundColor=[UIColor whiteColor];
[self.view addSubview:self.testView];
编辑 1
我已经更新了代码,所以前 4 条评论实际上是无关紧要的
编辑 2
@implementation JtViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end