简体   繁体   中英

Default size classes seem to only work for iPad (XCode 6)

I am trying to wrap my head around the new size classes in iOS8 and XCode6. I am attempting to create a nib, without a storyboard, and do something really simple--center a UIView on the screen.

Starting with a nib in the default size: w:Regular h:Regular, I place a 200x200 UIView onto the parent view and center it, then add contraints to pin it. In my preview pane, the UIView only shows up on the iPad view.

I need for this view to show up on iPads in lanscape and iPhones in portrait. I suppose some day i will understand why Apple thinks this is so much easier, but at the moment I'm bewildered.

When I switch my design view to any of the iPhone supported modes, the UIView disappears.

Even when I unpin the UIView and move it around in the design view, it never shows up in the iPhone view. In other words, I've tried everything to get this view to appear on an iPhone and nothing works.

Here is my UIView and settings:

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Obviously there is something I'm missing, but I'm getting really frustrated trying to figure it out. Can anyone offer a clue? Thanks!

It's because you defined your view only for the size classes Regular & Regular . For them to show up on the iPhone you will have to configure the view also for the appropriate size classes, which in case of the iPhone is Regular & Compact where (<height> & <width>) .

UPDATE : The views generally only show up in the size classes for which they are configured . You currently have Regular & Regular selected, this can be seen from your screenshot. This means you defined it only for the devices with size classes Regular & Regular , which is the iPad in both orientations.

在此处输入图片说明

You need to add the views also in the size class that you are targeting, which are the size classes of the iPhone.

在此处输入图片说明

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