Storyboard uiviewcontroller, 'custom class' not showing in drop down

后端 未结 25 1076
北荒
北荒 2020-12-08 01:34

I have a UIViewController I created in my apps storyboard, as well as a custom UIViewController subclass which I added to the project (and is correctly in the compile phase

相关标签:
25条回答
  • 2020-12-08 02:21

    For those of you who are still having this problem after trying all the way around is probably because you clicked the View instead of ViewController.

    You have to choose the file when ViewController is clicked.

    This solved my problem.

    0 讨论(0)
  • 2020-12-08 02:21

    Make sure you select View Controller to which you want to attach your class. The easy way is open Document Outline and choose your view controller (When you tap on it form the Storyboard sometimes it simply doesn't choose the object you meant).

    0 讨论(0)
  • 2020-12-08 02:22

    I happened to come across this problem, and had no luck after trying the previous suggestions. Finally I found the reason is the header file's type is set to C++ header. After changing it to C header (like all the other header files), the class appears in the drop list. Don't know why though... Possibly helpful for others so I post it here.

    0 讨论(0)
  • 2020-12-08 02:22

    be sure initially not adding the CustomViewController to any group or folder. place it in the root of your app.

    0 讨论(0)
  • 2020-12-08 02:23

    Try to clean your project, and also restart your Mac. One peculiar thing that I did was change all the Custom Classes names and build the project again. It worked!

    0 讨论(0)
  • 2020-12-08 02:26

    For macOS projects, creating a new class generated a class inheriting from NSObject instead on NSViewController.

    Change from

    import Cocoa
    
    class AppsViewController: NSObject {
    
    }
    

    to

    import Cocoa
    
    class AppsViewController: NSViewController {
    
    }
    
    0 讨论(0)
提交回复
热议问题