简体   繁体   English

为iOS(iPhone和iPad)制作两个故事板

[英]Making two storyboards for iOS (iPhone and iPad)

Is it possible to make only one application and inside of it make two storyboards, one for iPhone and one for iPad? 是否可以只制作一个应用程序,并在其中制作两个故事板,一个用于iPhone,一个用于iPad? I don't like the idea of running the app on iPad and clicking the 2x button. 我不喜欢在iPad上运行应用程序并单击2x按钮的想法。

My idea was to create two storyboards and have a beginning class that would check if the device you are using is an iPhone or an iPad and then redirect to the according storyboard after. 我的想法是创建两个故事板,并有一个开始类,将检查您使用的设备是iPhone还是iPad,然后重定向到相应的故事板。 I think it is a good idea cause the code is the same. 我认为这是个好主意,因为代码是一样的。

create two different storyboards and name them so they are easily specified which is which. 创建两个不同的故事板并命名它们,以便轻松指定哪个。 Then click on the file that allows you to change settings for your actual app. 然后单击允许您更改实际应用程序设置的文件。 and change the build to universal , then specify which storyboard you want to use! 并将构建更改为universal ,然后指定要使用的故事板!

there is a storyboard setting for iphone and ipad 有一个iphone和ipad的故事板设置

iPhone 苹果手机

在此输入图像描述

iPad iPad的

在此输入图像描述

Make sure the names of the storyboards are correctly set though 确保故事板的名称已正确设置

即使您已经创建了一个非通用的应用程序,只需将其更改为通用(目标 - >摘要),然后创建一个新的ipad故事板并确保在目标 - >摘要下设置主iphone故事板和主ipad故事板到正确的故事板。

Did you try creating new Universarl XCode project? 您是否尝试过创建新的Universarl XCode项目? If you create Universal project, there will be two Storyboards(One for iPhone and another one for iPad) created by default. 如果您创建通用项目,默认情况下将创建两个故事板(一个用于iPhone,另一个用于iPad)。 i think. 我认为。

I had to do this in a project recently... so first you should navigate to your projects target then click the summary button in the top bar you will then see a bar that says "iOS Application Target" in there you will see a drop down menu with a title that says Devices select the universal option. 我最近必须在一个项目中执行此操作...首先,您应该导航到您的项目目标,然后单击顶部栏中的摘要按钮,然后您将看到一个显示“iOS Application Target”的栏,您将看到它下拉菜单,标题为“设备”选择通用选项。 Now add a storyboard for the iPad. 现在为iPad添加一个故事板。 Now go back to the projects target and scroll down to the "iPad Deployment Info" section and set your new storyboard as the main storyboard in the text field here you can also add the iPad icon and launch images. 现在返回项目目标并向下滚动到“iPad部署信息”部分,并将新故事板设置为文本字段中的主要故事板,您还可以添加iPad图标和启动图像。 Now you are set up for creating a universal app! 现在您已经准备好创建通用应用程序了!

它非常简单,只需在universal执行应用程序然后转到目标然后信息然后添加主要storyborad文件基本名称(iPad)然后构建并运行iPhone运行到它的显示iPhone和iPad运行时显示为iPad兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM