简体   繁体   English

将ViewController连接到XCode中的.swift文件

[英]Connect ViewController to .swift file in XCode

As you can see in the image below, my View Controller (a Table view controller if that matters) is named "BasicPhrasesVC" and my .swift file is also named "BasicPhrasesVC". 如下图所示,我的View Controller(表视图控制器,如果重要)被命名为“BasicPhrasesVC”,我的.swift文件也被命名为“BasicPhrasesVC”。 Despite this the error "Unknown class BasicPhrasesVC in Interface Builder file." 尽管如此,错误“ Interface Builder文件中的未知类BasicPhrasesVC”。 keeps appearing. 不断出现。 I also did not rename them if it helps. 如果有帮助,我也没有重命名它们。

查看控制器问题图像

Thanks for any help in advance. 在此先感谢您的帮助。

in your BasicPhrasesVC.swift, the code should be something like this 在你的BasicPhrasesVC.swift中,代码应该是这样的

class BasicPhrasesVC {
  ....
}

the Class in your Interface builder should be the same as the class same in your file, it doesn't matter where you place your class. 界面”构建器中的“ 类”应与文件中的类相同 ,无论您在何处放置类都无关紧要。 At last, after you fix your class name, in your interface builder Custom Class -> Class, input the correct name and " press Enter " 最后,在修改类名后,在界面构建器Custom Class - > Class中输入正确的名称并“ 按Enter键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Xcode 7.1中使用Swift 2.0将UI连接到ViewController - Can't connect UI to ViewController using Swift 2.0 in Xcode 7.1 XCode 文本字段将无法连接到 ViewController - XCode Text Field will not connect to ViewController 如何在 Storyboard 中将 ViewController.swift 连接到 ViewController? - How to connect ViewController.swift to ViewController in Storyboard? Xcode 6-我无法将任何东西从我的IB连接到ViewController.swift - Xcode 6 - I Can't connect anything from my IB to ViewController.swift Xcode 6:无法将任何IBOutlet连接到ViewController - Xcode 6: can't connect any IBOutlet to ViewController 无法从 ViewController Xcode 将“按钮”连接到 viewcontroller.h - Cannot connect "button" to viewcontroller.h from a ViewController Xcode Xcode 9 swift 4动态可重用头文件,用于多个viewController - Xcode 9 swift 4 Dynamic reusable header for several viewController Xcode从viewcontroller.swift跳转到storyboard - Xcode jump from viewcontroller.swift to storyboard Xcode:在 ViewController.swift 中禁用视图的旋转 - Xcode: Disable rotation for a view in the ViewController.swift 如果当前viewController在tableView didSelect中导航,则为XCode swift 3 - XCode swift 3 if current viewController navigate in tableView didSelect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM