首页 百科知识 通用应用程序

通用应用程序

时间:2022-09-22 百科知识 版权反馈
【摘要】:通用的应用程序是为iPhone和iPad在一个单一的二进制文件中设计的应用程序。这有助于代码重用,并能够帮助更快进行更新。

通用的应用程序是为iPhone和iPad在一个单一的二进制文件中设计的应用程序。这有助于代码重用,并能够帮助更快进行更新。

1、创建一个简单的View based application(视图应用程序)

2、在文件查看器的右边,将文件ViewController.xib的文件名称更改为ViewController_iPhone.xib,如下所示

UniversalAppInterfaceRename

3、选择"File -> New -> File... ",然后选择User Interface,再选择View,单击下一步

NewIpadXib

4、选择iPad作为设备,单击下一步:

UniversalAppSelectDeviceType

5、将该文件另存为ViewController_iPad.xib,然后选择创建

6、在ViewController_iPhone.xib和ViewController_iPad.xibd的屏幕中心添加标签

7、在ViewController_iPhone.xib中选择identity inspector,设置custom class为ViewController

UniversalAppSetClass

8、更新AppDelegate.m中的 application:DidFinishLaunching:withOptions方法

9、在项目摘要中更新设备中为universal,如下所示:

UniversalAppSetDevices

运行该应用程序,我们会看到下面的输出

UniversalAppiPhone_Output

在iPad模拟器中运行应用程序,我们会得到下面的输出:

UniversalAppiPad_Output


免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈