这是mainViewController.m
中的代码:
#import "SideViewController.h"
- (void)viewDidLoad{
SideViewController *sideVC = [[SideViewController alloc] initWithFrame:CGRectMake(0, 0, 250,self.view.bounds.size.height)];
[self.navigationController.view addSubview:sideVC.view];
}
mainViewController
通过故事板嵌入 UINavigationController
sideViewController
已添加至<{1}}作为子视图,因为我需要它涵盖UINavigationController
以及它在iOS8模拟器上的显示方式:
我怎样才能让它适合屏幕界限?
答案 0 :(得分:0)
我猜autoresize mask解决了这个问题:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
sideVC = [SideViewController new];
[sideVC.view setFrame:CGRectMake(0, 0, 250,self.view.bounds.size.height)];
sideVC.view.autoresizingMask = UIViewAutoresizingNone;
}
return self;
}