1.正常情况下Main.storyBoard里面默认是Iphone,想要兼顾iPad和iPhone:
(1)创建新的storyBorad命名:iPad.storyBoard,
2、File--->duplicate,将文件命名为MainStoryboard_ipad.storyboard
3、在plist文件中添加两项,Main storyboard file base name (iPhone) (Main storyboard file base name 默认为iPhone版)和Main storyboard file base name (iPad),其值分别对应1和2的两个storyboard
4、右键MainStoryboard_ipad.storyboard,open as ---> source code,找到targetRuntime,将其修改为targetRuntime="iOS.CocoaTouch.iPad",
device id="ipad9_7",并加上下面代码:
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
5.选中项目,General ——> Deployment Info ——> Devices 改为 Universal
6.编译完成之后,重新拖进一个ViewController,就会看到 views as 为iPad的
7.完成,完美。