为什么我的自定义类没有出现在Interface Builder中的下拉菜单中? [英] Why aren't my custom classes appearing in the dropdown in Interface Builder?

查看:76
本文介绍了为什么我的自定义类没有出现在Interface Builder中的下拉菜单中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Interface Builder和Storyboards构建我的应用程序。我正在尝试将源代码连接到Storyboard中的 UIViewController ,但是自定义类下拉菜单中没有显示任何类。这是在Xcode 11 beta 2和Xcode 11 beta 4中发生的。



我已经尝试了一些解决方案



2)确保该类继承了View Controller类型:

 类CustomViewController:UIViewController 

3)重新加载xCode并检查是否启用了该类:




I am using Interface Builder and Storyboards to build my app. I am trying to connect my source code to my UIViewController in Storyboard, but none of my classes show up in the Custom Class dropdown menu. This is occurring in Xcode 11 beta 2 and Xcode 11 beta 4.

I've tried some solutions in this Stack Overflow answer, but they are not working. I've already done all of the following:

  • Relaunched Xcode
  • Deleted derived data
  • Reinstalled Xcode
  • Tried a different Storyboard
  • Recreated the UIViewController file
  • Made a new project (the problem even occurred there)
  • Typing the UIViewController name into the dropdown menu text field

None of the solutions worked and I have made sure that I was connected a UIViewController to the Storyboard not something else like a UIView. This is occurring with all of my UIViewControllers and UITableViewControllers.

(I wish I could show an image but I do not have enough reputation...)

I expected the UIViewControllers that I have created to appear in the custom class dropdown. I also surprised to find out that manually typing the view controller into the text field does not work. Instead, when I run the project, I just get this message in the console:

Unknown class ViewControllerName in Interface Builder file.

解决方案

It appears that your classes aren't added to the project target. Try this:

1) Make sure your classes are added to the right target membership on the Inspectors Panel on the right:

2) Make sure the class inherits the View Controller type:

class CustomViewController: UIViewController

3) Reload xCode and check if the class is enabled:

这篇关于为什么我的自定义类没有出现在Interface Builder中的下拉菜单中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆