在 Xcode 8 中为我现有的 ViewController 文件创建 UIViewController xib 文件

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

Create UIViewController xib file for my existing ViewController file in Xcode 8

iosobjective-cxcodeuiviewcontrollerinterface-builder

提问by Prav

I have an existing View Controller file with a set of code. I want to create an interface builder file for the ViewController and link them. Right now i don't seem to find UIViewController option in the New file options as give here. enter image description here

我有一个带有一组代码的现有视图控制器文件。我想为 ViewController 创建一个界面构建器文件并链接它们。现在我似乎没有在新文件选项中找到 UIViewController 选项,因为这里给出。 在此处输入图片说明

Can any body tell me how to achieve this?

任何机构都可以告诉我如何实现这一目标吗?

回答by salman khalid

Now Apple preferably recommend to use storyboard as its easy to use and handle view controllers but still if you want to create separate view controller Please follow these steps.

现在 Apple 推荐使用 storyboard,因为它易于使用和处理视图控制器,但如果你想创建单独的视图控制器,请按照以下步骤操作。

1- Create objective c file or swift as you like
2- Change the UIView class to UIViewController
3- Create xib file
4- Add UIViewController object as shown in pic
5- Select the controller go to the 'Show inspector identity' and set the controller custom class

1-根据需要创建目标 c 文件或 swift
2-将 UIView 类更改为 UIViewController
3- 创建 xib 文件
4-添加 UIViewController 对象,如图
5-选择控制器转到“显示检查员身份”并设置控制器自定义类

回答by Prav

Just found out that I need to create an empty xib and then include the view controllers as needed. And then follow the instructions as suggested by kkRocks suggested url will link the existing view controller to the new xib.

刚刚发现我需要创建一个空的 xib,然后根据需要包含视图控制器。然后按照 kkRocks 建议的 url 建议的说明将现有视图控制器链接到新的 xib。