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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13614043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:12:35  来源:igfitidea点击:

Making two storyboards for iOS (iPhone and iPad)

iphoneiosxcodeipad

提问by Cartman

Is it possible to make only one application and inside of it make two storyboards, one for iPhone and one for iPad? I don't like the idea of running the app on iPad and clicking the 2x button.

是否可以只制作一个应用程序并在其中制作两个故事板,一个用于 iPhone,一个用于 iPad?我不喜欢在 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. I think it is a good idea cause the code is the same.

我的想法是创建两个故事板,并有一个开始类来检查您使用的设备是 iPhone 还是 iPad,然后重定向到相应的故事板。我认为这是一个好主意,因为代码是相同的。

回答by Bad_APPZ

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

苹果手机

enter image description here

在此处输入图片说明

iPad

iPad

enter image description here

在此处输入图片说明

Make sure the names of the storyboards are correctly set though

确保故事板的名称设置正确

回答by user1858163

Even if you already made an app non universal, just change it to universal (target-->summary), then create a new ipad story board and make sure under target-->summary that the main iphone storyboard and main ipad storyboard are set to the right storyboards.

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

回答by Sage Washabaugh

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. Now add a storyboard for the 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. Now you are set up for creating a universal app!

我最近不得不在一个项目中这样做......所以首先你应该导航到你的项目目标,然后点击顶部栏中的摘要按钮,然后你会看到一个写着“iOS Application Target”的栏,你会看到一个下拉标题为“设备选择通用选项”的下拉菜单。现在为 iPad 添加一个故事板。现在返回到项目目标并向下滚动到“iPad 部署信息”部分,并将您的新故事板设置为文本字段中的主故事板,您还可以在此处添加 iPad 图标和启动图像。现在您已准备好创建通用应用程序!

回答by Paramasivan Samuttiram

Did you try creating new Universarl XCode project? If you create Universal project, there will be two Storyboards(One for iPhone and another one for iPad) created by default. i think.

您是否尝试创建新的 Universarl XCode 项目?如果您创建 Universal 项目,默认会创建两个 Storyboard(一个用于 iPhone,另一个用于 iPad)。我认为。

回答by Hitendra Lariya

its very simple, just do the app in universaland then go to the target and then info and then add the main storyboradfile base name (iPad) then build and run when iPhone is run to its show iPhone and when iPad run so show as iPad.

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