如何使用带有StoryBoards的Xcode 4.2空应用程序模板创建通用应用程序? [英] How to create a Universal Application using Xcode 4.2 Empty Application Template with StoryBoards?

查看:124
本文介绍了如何使用带有StoryBoards的Xcode 4.2空应用程序模板创建通用应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的xcode版本更新为4.2并且即将使用带有故事板的空应用程序模板制作通用应用程序。我不知道如何使用故事板开始这个东西而不是通常的.xibs用于GUI。请帮帮我们非常感谢!

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!

推荐答案

您可以通过为每个设备创建单独的故事板并将设备的入口点设置为目标摘要中的相应故事板。

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.

详细说明如下。

创建一个空的通用应用程序后,您需要为每个设备创建单独的故事板。

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

文件 - >新建 - >文件 - >用户界面 - >故事板 - >(MainStoryboard_iPad& MainStoryboard_iPhone)

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

在每个故事板中,您需要插入至少一个视图控制器。您可以通过拖动单个视图控制器和每个故事板的标签来验证功能(标记一个iPad和一个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").

在故事板到位后,您需要为视图控制器添加代码。 Apple建议为每个设备添加一个单独的视图控制器,但如果你真的想要,你可以共享一个视图控制器。

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.

文件 - >新建 - >文件 - > ViewController - >(HomeViewController_iPad& HomeViewController_iPhone)

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

导航回相应的故事板,选择您插入的视图控制器,并设置视图身份检查器中的控制器(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.

此时,运行应用程序将在相应的设备上显示iPad和iPhone。

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

这篇关于如何使用带有StoryBoards的Xcode 4.2空应用程序模板创建通用应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆