xcode 如何添加新的xib文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7166663/
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
How to add new xib files
提问by ilaunchpad
I have to develop an app with multiple screens. I have automatically generated xib file, but for my other screen I need another xib file. How do I create another xib file?
我必须开发一个具有多个屏幕的应用程序。我已经自动生成了 xib 文件,但是对于我的另一个屏幕,我需要另一个 xib 文件。如何创建另一个 xib 文件?
采纳答案by codelark
(Assuming XCode 4)
(假设 XCode 4)
In the "File -> New File..." menu dialog, there is a subsection called "User Interface."
在“文件 -> 新建文件...”菜单对话框中,有一个名为“用户界面”的小节。
You will notice in the description of each of the sub-items, it says "An Interface Builder Document." Those are various types of nibs.
您会在每个子项的描述中注意到,它写着“一个接口构建器文档”。这些是各种类型的笔尖。
If you're creating a new ViewController
specifically, you can also choose the "Cocoa Touch" section and select the "UIViewController subclass" item. There is a checkbox in the next page called "With XIB for User Interface." which will create the NIB as well as the associated class files.
如果你ViewController
专门创建一个新的,你也可以选择“Cocoa Touch”部分并选择“UIViewController subclass”项。下一页中有一个名为“使用 XIB 用于用户界面”的复选框。这将创建 NIB 以及相关的类文件。
回答by Evan Mulawski
In XCode 4:
在XCode 4 中:
To create a standalone user interface (XIB):
要创建独立用户界面 (XIB):
File -> New File -> iOS -> User Interface
文件 -> 新建文件 -> iOS -> 用户界面
Then choose:
然后选择:
- Application (includes delegate and window)
- Window
- View
- Empty
- 应用程序(包括委托和窗口)
- 窗户
- 看法
- 空的
To create a new UIViewController
class with a user interface:
要UIViewController
使用用户界面创建新类:
File -> New File -> iOS -> Cocoa Touch -> UIViewController subclass -> Click Next
文件 -> 新建文件 -> iOS -> Cocoa Touch -> UIViewController 子类 -> 点击下一步
Then, name the new view controller class and select "With XIB for user interface."
然后,命名新的视图控制器类并选择“With XIB for user interface”。
回答by xhinoda
For XCode 8 and swift 3:
对于 XCode 8 和 swift 3:
File -> New File -> iOS -> User Interface -> View
文件 -> 新建文件 -> iOS -> 用户界面 -> 查看
Name it "YourViewController.xib" and saved it.
将其命名为“YourViewController.xib”并保存。
回答by Vladan
回答by raycamwu
In XCode 5: ( Created a NEW someVC.xib when you just Deleted your old someVC.xib )
在 XCode 5 中:(当您刚刚删除旧的 someVC.xib 时创建了一个新的 someVC.xib)
more Steps need to done:
需要做的更多步骤:
tap : ClassNameWithViewController.xib , as processes in last answer , and IB opened
tap : ClassNameWithViewController.xib ,作为上一个答案中的进程,并且 IB 打开
choice: File's owner
选择:文件的所有者
tap : Identity Inspector
点击:身份检查员
in [Custom Class] -> pull-down the [Class] window to selected -> ClassNameWithViewController
在 [Custom Class] -> 下拉 [Class] 窗口到选中 -> ClassNameWithViewController
back to tap : File's owner
返回点击:文件的所有者
2 finger tap : File's owner -> open the Links Menu -> drag a line from [view's small-circle] to [View] in IB
2 指点击:文件的所有者 -> 打开链接菜单 -> 从 [视图的小圆圈] 拖动一条线到 IB 中的 [视图]