简体   繁体   English

Xcode 7.3如何将现有的iPhone应用程序转换为通用应用程序,以便在iOS中使用iPad

[英]Xcode 7.3 How to Convert my existing iPhone application to universal app, for work with iPad in iOS

Previously, it is only an iPhone application. 以前,它只是一个iPhone应用程序。 Now I want it run in iPad as well. 现在,我希望它也可以在iPad中运行。 So I chose the target as universal, but when I run it in iPad simulator. 所以我选择了通用目标,但是当我在iPad模拟器中运行它时。 It only remains the color of the view without any labels and textfields. 它仅保留视图的颜色,没有任何标签和文本字段。 一般

How can I make the application run properly both in iPad and iPhone? 如何使该应用程序在iPad和iPhone上都能正常运行?

Step 1 : First You need to change your size Class to wAny x hAny . 步骤1:首先,您需要将Class的大小更改为wAny x hAny Now when you open your controller all your controls will be visible as disabled, Because you change your size class and constraints defined are not compatible with it. 现在,当您打开控制器时,所有控件都将显示为已禁用,因为您更改了大小类,并且定义的约束与之不兼容。

不同大小的控件类别

Step 2 : Now select all your controls in your controller then goto bottom of Attribute Inspector. 步骤2:现在,在控制器中选择所有控件,然后转到Attribute Inspector的底部。 You will see checkbox for C x Any . 您将看到C x Any的复选框。 uncheck it. 取消选中它。

在此处输入图片说明

Step3 : Now you have to add new Constraint for Any x Any . 第三步:现在您必须为Any x Any添加新的约束。 As you have already changed your size class to **Any x Any ** just check above check box which will by default activate constrains for current size class. 由于您已经将尺寸等级更改为**任何x任何**,只需选中上方的复选框即可,默认情况下会激活当前尺寸等级的约束。

激活当前约束。

Step 4 : Then you need to add missing constraints which ever necessary for your controls. 第4步:然后,您需要添加缺少的约束,这些约束对于您的控件都是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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