IOS development-building an adaptive iPhone and iPad Project

Source: Internet
Author: User

Sometimes the application needs to be able to run on the iPhone and iPad. Of course we can choose to do two completely different projects and share some classes, but we can also create only one project, then compile and generate a product that can adapt to the iPhone and iPad devices. Then, when the app stroe is released, it will display two different sets of products to users. The Evernote application on App Store has two iPhone and iPad sets. This shows that Evernote is an adaptive iPhone and iPad device.

 

Let's build an adaptive iPhone and iPad device named universalsample.

First, select "devices" as "universal" during creation. We have always selected the iPhone. If you want to develop an iPad-specific application, select the iPad.

After creation, two storyboards are generated. If NiB is used, two sets of files are generated.

Select targets. The iPhone "Main storyboard" (main story board) is set to mainstoryboard_iphone. The main story board is first loaded when the application is started, it sets the Root View of the application and the first screen to start. For iPad (main story board), set mainstoryboard_ipad.

When running, you need to select the running device, which has several options: iPad 6.0 simulator, iPhone 6.0 simulator, and iOS device (real machine running). Select iPhone 6.0 simulator, this indicates that the application needs to run on the iPhone 6.0 simulator.

During programming, you can use the following statement to determine the device. The constant uiuserinterfaceidiomphone is used to determine whether the device is an iPhone device. uiuserinterfaceidiompad is used to determine whether the device is an iPad device.

If ([[uidevice currentdevice] userinterfaceidiom] = uiuserinterfaceidiomphone) {// iPhone} else {// iPad}

 

For more information about ios6 open, see ios6 open guide.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.