简体   繁体   中英

Autolayout not detecting frame size

I'm converting my xib files to use autolayout but only certain devices have their frame size detected properly (iPad 2 and iPhone 4). The iPhone 6plus and iPhone 6 that I'm using doesn't detect the frame size properly. It detects the frame size of the view.

I've initiated the self.view.frame.size.height and self.view.frame.size.width in the viewWillAppear method but it's still not detecting the correct size. This is making my auto layout not scale properly. Any suggestions?

You should use this method to get the correct size:

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    //YOUR CODE HERE
}

The view final size is not setted until the call of the "viewDidLayoutSubviews" method. Here we will have the correct size of the view. I hope that will resolve your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM