简体   繁体   中英

Load UIView from XIB incorrect size

I'm new to iOS 8, I tried to load a UIView from XIB file with auto layout and size classes option are enabled. I use Inferred size XIB with default size is 600 x 600. But on the simulator the size of view is not fit screen size, it still be 600 x 600 and doesn't fit the screen size like this, it's much bigger than the screen on width: 在此处输入图片说明

But when I use View Controller widget, it has Resize of NIB option, and it work fine to fit the screen size. Can anybody suggest what should I do to resize UIView to fit screen size? Thank you very much, guys!

Update: Here is how I call it: 在此处输入图片说明

And constraint I use: 在此处输入图片说明

You should use autolayout and set constraint. It is better choice if you need to support multiple device.

Try to figure out with these 3 images first. Then I am discussing one by one.

http://imgur.com/mE2dNm8

http://imgur.com/PVW6yrk

http://imgur.com/LLZkMgx

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