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.

 

650) this. length = 650; "width =" 577 "height =" 614 "class =" aligncenter size-full wp-image-302 "alt =" 1 "src =" http://www.bkjia.com/uploads/allimg/131228/0AI56044-0.jpg "_ xhe_src =" http://www.bkjia.com/uploads/allimg/131228/0AI56044-0.jpg "style =" max -width: 98%; "/>

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.

650) this. length = 650; "width =" 523 "height =" 281 "class =" aligncenter size-full wp-image-303 "alt =" 2 "src =" http://www.bkjia.com/uploads/allimg/131228/0AI562U-2.jpg "_ xhe_src =" http://www.bkjia.com/uploads/allimg/131228/0AI562U-2.jpg "style =" max -width: 98%; "/>

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

650) this. length = 650; "width =" 449 "height =" 316 "class =" aligncenter size-full wp-image-304 "alt =" 3 "src =" http://www.bkjia.com/uploads/allimg/131228/0AI524V-4.jpg "_ xhe_src =" http://www.bkjia.com/uploads/allimg/131228/0AI524V-4.jpg "style =" max -width: 98%; "/>

Select TARGETS, and set MainStoryboard_iPhone as the Main Storyboard of the iPhone. The Main Storyboard is first loaded when the application is started, it sets the Root View of the application and the first screen to start. The main story board of the iPad), which is set to MainStoryboard_iPad.

650) this. length = 650; "width =" 471 "height =" 339 "class =" aligncenter size-full wp-image-305 "alt =" 4 "src =" http://www.bkjia.com/uploads/allimg/131228/0AI5AO-6.jpg "_ xhe_src =" http://www.bkjia.com/uploads/allimg/131228/0AI5AO-6.jpg "style =" max -width: 98%; "/>

When running, you need to select the running Device, which has the following options: iPad 6.0 Simulator, iPhone 6.0 Simulator, and iOS Device, this indicates that the application needs to run on the iPhone 6.0 simulator.

650) this. length = 650; "width =" 460 "height =" 215 "class =" aligncenter size-full wp-image-306 "alt =" 5 "src =" http://www.bkjia.com/uploads/allimg/131228/0AI54526-8.jpg "_ xhe_src =" http://www.bkjia.com/uploads/allimg/131228/0AI54526-8.jpg "style =" max -width: 98%; "/>

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.

 

 
 
  1. If ([[UIDevice currentDevice] userInterfaceIdiom] = UIUserInterfaceIdiomPhone ){
  2.  
  3. // IPhone Device
  4.  
  5. } Else {
  6.  
  7. // IPad Device
  8.  
  9. }

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

This article from the "Guan Dongsheng" blog, please be sure to keep this source http://2009315319.blog.51cto.com/701759/1183731

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.