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.