我有一個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也許? –
我沒有使用任何自動佈局 –