我有一个ViewController,里面嵌入了一个scrollView。在这个滚动视图中,我添加了4个视图,它们是XIB文件视图。 XIB文件大小是“推断”,虽然看起来是iphone5大小。加载时,它们不会自动调整大小以适应屏幕大小,它们停留在iphone5大小。将XIB文件自动调整为屏幕大小
如何让XIB文件的大小与其加载的屏幕大小相同?
编辑:
我自己也尝试过这样的代码改变笔尖文件大小:
// 1) Create the three views used in the swipe container view
let AVc :AViewController = AViewController(nibName: "AViewController", bundle: nil);
let BVc :BViewController = BViewController(nibName: "BViewController", bundle: nil);
let CVc :CViewController = CViewController(nibName: "CViewController", bundle: nil);
let DVc :DViewController = DViewController(nibName: "DViewController", bundle: nil);
AVc.view.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height)
BVc.view.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height)
CVc.view.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height)
DVc.view.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height)
// 2) Add in each view to the container view hierarchy
// Add them in opposite order since the view hieracrhy is a stack
self.addChildViewController(DVc);
self.scrollView!.addSubview(DVc.view);
DVc.didMoveToParentViewController(self);
self.addChildViewController(CVc);
self.scrollView!.addSubview(CVc.view);
CVc.didMoveToParentViewController(self);
self.addChildViewController(BVc);
self.scrollView!.addSubview(BVc.view);
BVc.didMoveToParentViewController(self);
self.addChildViewController(AVc);
self.scrollView!.addSubview(AVc.view);
AVc.didMoveToParentViewController(self);
这仍然没有影响,它加载了错误的大小。
autolayout也许? –
我没有使用任何自动布局 –