ios 界面生成器文件中的 Xcode 7.1 Swift 2 未知类

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

Xcode 7.1 Swift 2 Unknown class in Interface Builder file

iosxcodeswiftcocoa

提问by Alex Belke

I've created new Cocoa Touch File. Named it SwipingViewController. enter image description here

我创建了新的 Cocoa Touch 文件。将其命名为 SwipingViewController。 在此处输入图片说明

Then try to add Custom Class to ViewController.

然后尝试将自定义类添加到 ViewController。

And when I run the app I receive an error

当我运行应用程序时,我收到一个错误

2015-10-09 10:53:25.054 ParseStarterProject[5369:389307] Unknown class SwipingViewController in Interface Builder file.

2015-10-09 10:53:25.054 ParseStarterProject[5369:389307] 界面生成器文件中的未知类 SwipingViewController。

Unknown class SwipingViewController in Interface Builder file

Interface Builder 文件中的未知类 SwipingViewController

Related: Xcode 6 Strange Bug: Unknown class in Interface Builder file

相关: Xcode 6 Strange Bug:Interface Builder 文件中的未知类

Here is my projects files

这是我的项目文件

回答by Nakul

In storyboard below the Custom Class field the module is set to None. Change that to your app module or just remove and enter class again, it should set to default like this:

在自定义类字段下方的故事板中,模块设置为无。将其更改为您的应用程序模块或只是删除并再次输入类,它应该设置为默认值,如下所示:

回答by Rodrigo Gonzalez

For me the problem was that the class was not part of the Target Membership. Just add the class to the target, and you should see it back on the interface builder.

对我来说,问题是该类不是Target Membership. 只需将类添加到目标,您应该会在界面构建器上看到它。

Target Membership

目标会员

回答by Yuchen Zhong

Still seeing this problem with XCode 8.2.1, but I am able to fix the problem by modify these in the storyboard xml file:

仍然在XCode 8.2.1 上看到这个问题,但我可以通过在 storyboard xml 文件中修改这些来解决这个问题:

  1. Delete customModuleProvider="target"in the viewControllertag:

    - <viewController ... customModule="Flights" customModuleProvider="target" sceneMemberID="viewController">
    + <viewController ... customModule="Flights" sceneMemberID="viewController">
    
  2. Delete customModule="Flights" customModuleProvider="target"in the widget tag (in my case, a labeltag):

    - <label ... translatesAutoresizingMaskIntoConstraints="NO" id="PzF-6K-Hpi" customClass="YZLabel" customModule="Flights" customModuleProvider="target">
    + <label ... translatesAutoresizingMaskIntoConstraints="NO" id="PzF-6K-Hpi" customClass="YZLabel">
    
  1. customModuleProvider="target"viewController标签中删除:

    - <viewController ... customModule="Flights" customModuleProvider="target" sceneMemberID="viewController">
    + <viewController ... customModule="Flights" sceneMemberID="viewController">
    
  2. customModule="Flights" customModuleProvider="target"在小部件标签中删除(在我的例子中,是一个标签标签):

    - <label ... translatesAutoresizingMaskIntoConstraints="NO" id="PzF-6K-Hpi" customClass="YZLabel" customModule="Flights" customModuleProvider="target">
    + <label ... translatesAutoresizingMaskIntoConstraints="NO" id="PzF-6K-Hpi" customClass="YZLabel">
    

I find that step 1 is very important too to resolve the crash/warning and cannot be skipped.

我发现第 1 步对于解决崩溃/警告也非常重要,不能跳过。

回答by sagnitude

I resolved a similar issue by adding '-ObjC' to 'Other linker flags' in the 'Build Settings' of my project.

我通过在我的项目的“构建设置”中将“-ObjC”添加到“其他链接器标志”来解决了类似的问题。

回答by kev

i had a similar issue as well. I had a ViewController with a TableView in it, and the tableView's custom class was called 'ViewController'. I just deleted the custom class for the tableView and the error went away.

我也有类似的问题。我有一个带有 TableView 的 ViewController,tableView 的自定义类被称为“ViewController”。我刚刚删除了 tableView 的自定义类,错误就消失了。

回答by Mijail

I solved it by manually writing the module name in the storyboard, under the class name. In my case it was the same name as the class, but it may differ.

我通过在故事板中的类名下手动编写模块名称来解决它。就我而言,它与类同名,但可能不同。

回答by Kiryl Ivanou

For me: for table view cell in 'Indentity Inspector' unchecked 'Inherit Module From Target' and cleaned the project. It solved the problem and project run successfully

对我来说:对于“身份检查器”中的表格视图单元格,取消选中“从目标继承模块”并清理项目。问题解决,项目运行成功

回答by RaviM

I resolved this issue by applying view controller initialise. View-controller basic declaration of view did load method and class implementation in *.swift class shows in storyboard.

我通过应用视图控制器初始化解决了这个问题。视图的视图控制器基本声明在故事板中显示了 *.swift 类中的加载方法和类实现。