如何检测程序运行在ipad上

1. How to check if app is running on iPad?

Using Runtime Checks to Create Conditional Code Paths

If your code needs to follow a different path depending on the underlying device type, you can use the userInterfaceIdiom property of UIDevice to determine which path to take. This property provides an indication of the style of interface to create: iPad or iPhone. Because this property is available only in iPhone OS 3.2 and later, you must determine if it is available before calling it. The simplest way to do this is to use the UI_USER_INTERFACE_IDIOM macro as shown below:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
     // The device is an iPad running iPhone 3.2 or later.
}
else
{
     // The device is an iPhone or iPod touch.
}

2. How to upgrade iphone project to iPad?

If you are updating an existing project, you can use Xcode’s Upgrade Current Target for iPad command to update your project:

-Open your Xcode project.
-In the Targets section, select the target you want to update to a universal application.
-Select Project > Upgrade Current Target for iPad and follow the prompts to create one universal application.
-Xcode updates your project by modifying several build settings to support both iPhone and iPad.

Important: You should always use the Upgrade Current Target for iPad command to migrate existing projects. Do not try to migrate files manually.

3. How to use single Xcode project to build 2 app?

Maintaining a single Xcode project for both iPhone and iPad development simplifies the development process tremendously by allowing you to share code between two separate applications. The Project menu in Xcode includes a new Upgrade Current Target for iPad command that makes it easy to add a target for iPad devices to your existing iPhone project. To use this command, do the following:

-Open the Xcode project for your existing iPhone application.
-Select the target for your iPhone application.
-Select Project > Upgrade Current Target for iPad and follow the prompts to create two device-specific applications.

Important: You should always use the Upgrade Current Target for iPad command to migrate existing projects. Do not try to migrate files manually.


In the below link you may find more details about your questions.

https://developer.apple.com/iphone/prerelease/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

無名VF

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值