ios 在 Xcode 中创建一个新的故事板并使其成为主要的故事板(模拟器中的黑屏)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38290404/
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-08-31 09:40:19  来源:igfitidea点击:

Creating a new storyboard in Xcode and making it the main one (black screen in simulator)

iosxcode

提问by evanhaus

I accidentally deleted my original Main.storyboard file that came with the project when I first began it. Now, I need all of the steps necessary to create a new storyboard and make it the new main storyboard for the project. I only need one storyboard. When I run my app in simulator my whole app is just a black screen. Any help would be greatly appreciated. I am programming in Swift.

我第一次开始时不小心删除了项目附带的原始 Main.storyboard 文件。现在,我需要所有必要的步骤来创建一个新的故事板并使其成为项目的新主故事板。我只需要一个故事板。当我在模拟器中运行我的应用程序时,我的整个应用程序只是一个黑屏。任何帮助将不胜感激。我正在用 Swift 编程。

回答by Devapploper

You need to make the following things to get it to work:

您需要进行以下操作才能使其正常工作:

1.Create a new file

1.新建一个文件

Add file

添加文件



2.Select, name and save the Storyboard file

2.选择、命名并保存 Storyboard 文件

Storyboard

故事板



3.Select the file in the Deployment Info

3.Deployment Info中选择文件

deployment info

部署信息



4.Drag a view controller into the file and select it as initial view controller (look at the inspector on the right)

4.将一个视图控制器拖入文件并选择它作为初始视图控制器(查看右侧的检查器)

view controller

视图控制器

回答by tryKuldeepTanwar

Let Me come up with a better solution

让我想出一个更好的解决方案

Method 1

方法一

if you have deleted the story board as remove refrence like this

如果你已经删除了故事板,像这样删除引用

enter image description here

在此处输入图片说明

don't worry about anything your storyboard is still safe.

不要担心你的故事板仍然安全。

inside your project suppose you have your project saved on desktop as project1 go to project1 then you'll see a couple of folders find a folder named project1

在您的项目中,假设您将项目保存在桌面上,作为 project1 转到 project1 然后您会看到几个文件夹找到一个名为project1的文件夹

Open it and you'll see some file's like this

打开它,你会看到一些这样的文件

enter image description here

在此处输入图片说明

all you have to do is go to Base.ipoj folder and if you find these files

您所要做的就是转到 Base.ipoj 文件夹,如果您找到这些文件

enter image description here

在此处输入图片说明

either you can drag the file to your project or you can add them by this way.

您可以将文件拖到您的项目中,也可以通过这种方式添加它们。

enter image description here

在此处输入图片说明

browse your file For example desktop/project1/project1/Base.Iproj/Main.Storyboard

浏览您的文件例如 desktop/project1/project1/Base.Iproj/Main.Storyboard

enter image description here

在此处输入图片说明

click on Add button and you'll have your Storyboard file.

单击“添加”按钮,您将拥有 Storyboard 文件。

and if you deleted the file by selecting "Move to trash" You can look up into trash copy your file to another folder and add the file as mentioned in the above steps.

如果您通过选择“移至垃圾箱”删除了文件,您可以查看垃圾箱,将您的文件复制到另一个文件夹,然后按照上述步骤添加该文件。

Method 2

方法二

if you want to add a new Storyboard just do :-

如果您想添加一个新的故事板,请执行以下操作:-

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

click on Next and save it and You'll have your new Storyboard.

单击 Next 并保存它,您将拥有新的 Storyboard。

回答by tryKuldeepTanwar

I Also noticed that you have asked about assign the storyboard's view controller as the main one :-

我还注意到您询问了将故事板的视图控制器分配为主要控制器的问题:-

here's the way :-

这是方法:-

enter image description here

在此处输入图片说明

Click on View Controller

单击视图控制器

enter image description here

在此处输入图片说明

Open Attribute Inspector

打开属性检查器

enter image description here

在此处输入图片说明

Select View Controller as the initial one and you're ready to go.

选择 View Controller 作为初始控制器,您就可以开始了。

回答by Abd Aboudi

Add new storyboard(New File..User Interface) ,then go to project's target ,then in (Main Interface) field add your storyboard name .

添加新的故事板(新文件..用户界面),然后转到项目的目标,然后在(主界面)字段中添加您的故事板名称。