How to create a Universal Application using Xcode 4.2 Empty Application Template with StoryBoards?

雨燕双飞 提交于 2019-12-08 03:02:31

问题


I updated my xcode version to 4.2 and about to make a universal application using empty application template with storyboards. I don't know how to start with this thing using storyboards not the usual .xibs for GUI. Please help guys. Thanks a lot!


回答1:


You can accomplish this by creating separate story boards for each device and setting the entry point for the devices to the appropriate story board in your target summary.

Detailed instructions follow.

Once you have created an empty, universal application, you'll want to create separate story boards for each device.

File -> New -> File -> User Interface -> Storyboard -> (MainStoryboard_iPad & MainStoryboard_iPhone)

Within each storyboard you'll need to insert at least one view controller. You can verify functionality by dragging in a single view controller and a label for each story board (label one "iPad" and one "iPhone").

With the story boards in place you need to add the code for the view controllers. Apple recommends adding a separate view controller for each device, but you could potentially share a single view controller if you really wanted to.

File -> New -> File -> ViewController -> (HomeViewController_iPad & HomeViewController_iPhone)

Navigate back to the respective story boards, select the view controller you inserted, and set the view controllers (HomeViewController_iPad & HomeViewController_iPhone) in the identity inspector. Then add the referencing outlet by right clicking the view and dragging add referencing outlet onto the view controller and selecting view.

Finally, you need to set the entry point for each device. Navigate to your target summary and select the Main Storyboard for each device to the story boards you have just created.

At this point, running the app will display "iPad" and "iPhone" on the respective devices.



来源:https://stackoverflow.com/questions/8890111/how-to-create-a-universal-application-using-xcode-4-2-empty-application-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!