Unable to select custom class for ViewControllers in Xcode Storyboard

社会主义新天地 提交于 2019-12-05 03:06:31

When you are in the storyboard, Interface Builder of Xcode, make sure you click on black colored bar under the view:

This will select the view controller (not the view) in the storyboard. Notice how the whole scene has a blue border around it. Once this is selected, you can set the class of the view controller in the Identity Inspector.

kordiseps

I finally solved it. You must save your work and quit xcode. But look don't close, you have to quit xcode.

When you run xcode again, you will see your viewcontroller that you just created.

Also, make sure your view controller type (e.g. TableViewController) in your storyboard matches your view controller super class (e.g. TableViewController). Otherwise, it won't show up in the list of classes to choose from.

For me, the problem was that my class extended a class from another framework, explicitly including the package name, eg:

class BaseMessageController: MessageKit.MessagesViewController

The fix was dropping the framework name:

class BaseMessageController: MessagesViewController

Might be an Apple bug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!