简体   繁体   中英

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

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.

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

1. Create a new file

添加文件


2. Select, name and save the Storyboard file

故事板


3. Select the file in the Deployment Info

部署信息


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

视图控制器

Let Me come up with a better solution

Method 1

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

在此处输入图片说明

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

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

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

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

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 :-

在此处输入图片说明

在此处输入图片说明

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

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

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

here's the way :-

在此处输入图片说明

Click on View Controller

在此处输入图片说明

Open Attribute Inspector

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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