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.
- If ([[UIDevice currentDevice] userInterfaceIdiom] = UIUserInterfaceIdiomPhone ){
-
- // IPhone Device
-
- } Else {
-
- // IPad Device
-
- }
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