Storyboard uiviewcontroller, "custom class" does not appear in the drop-down list

I have a UIViewController that I created in the storyboard of my applications, as well as a custom subclass of UIViewController that I added to the project (and correctly at compile time for my purpose). However, when I am going to set the "Custom Class" property on the view controller in the Storyboard, my custom class does not appear in the list.

  • Checked that the class is part of my target program, not tests
  • Double checked that it is the correct subclass of UIViewController
  • A compiled program to make sure xcode works with the latest information.
  • Rebooted xcode

What could cause my class to not appear in the Custom Class drop-down list?

+59
ios storyboard
Jan 02 '13 at 22:22
source share
23 answers

There are two ways to find a solution to the problem, but they work. 1. Simply enter the name of the view manager in the text box or 2. close the project, then open it again and in the initialization of the project it will put the file in the list.

+42
Jan 04 '13 at 0:26
source share

If you still have a problem or those who may have the same problem:

Be sure to select your "ViewController" in your storyboard instead of "View" (which is automatically selected when you click on the view in the storyboard). The difference between the two is that when a view controller is selected, a blue rectangle appears around your application. To select a view controller, open the document outline and select it directly in the storyboard hierarchy.

enter image description hereenter image description hereenter image description here

+41
Feb 24 '14 at 17:57
source share

I would try the following:

  1. Make sure that the file that implements this class is part of the build phases (verification by the steps target > build )
  2. Add the .m file to build the phases (if it is not already).
  3. Restart Xcode.
+12
Jan 2 '13 at 22:51
source share

You can fix this by editing the XML of your storyboard.

  • Right-click on your My.storyboard in the Project Navigator panel and select Open As-> SourceCode. Locate the entry in the view controller in XML and add the attribute customClass="MyController" .

  • Save the storyboard.

  • Right-click again on your My.storyboard in the Project Navigator panel and select Open As> - Interface Builder - Storyboard.

The custom class entry will now contain your MyController class MyController .

+11
Jul 31 '15 at 2:28
source share

Make sure your class inherits from UIViewController.

 @interface ClassName : UIViewController 
+6
Jan 02
source share

In Xcode 8, some of my classes had the wrong path (case sensitive) specified for the location of the files.

 MyProject/mysubdirectory/MyViewController.xib (.m, .h) 

vs:

 MyProject/mysubdirectory/MyViewController.xib (.m, .h) 

Not really sure how it ended up in this state, but my project showed the same behavior as above (doesn't display outputs / actions in IB), and fixing this path fixes the problem.

I fixed this in two different ways. One way was: I opened the .pbxproj file and fixed the case-sensitive problem manually. Another way that worked is to click the folder icon in the “Identification and Type” section of the “File Inspector” tab of the file and reselect the file there.

+4
Jan 02 '17 at 0:00
source share

I had the same problems as in this problem. However, none of the suggested answers fixed this for me. My project was compiled without warnings or errors, but there were no “exit” indicators in the .h file to indicate that my outputs were associated with storyboard elements.

In addition, attempts to create new points in my code by right-clicking and dragging into my header file did not recognize my header source as a potential target for this operation. In addition, my class did not appear in the Custom-Class drop-down list for the ViewController Property Inspector panel.

Still, the project compiled in order.

A more thorough examination showed that I defined my class as follows ...

 @interface KJBMainDataViewTrackConMk2<UIScrollViewDelegate> : UIViewController 

which seems to compile nicely.

But if this is changed to the following (moving protocols to the end) ...

 @interface KJBMainDataViewTrackConMk2 : UIViewController<UIScrollViewDelegate> 

Then everything comes to life. All outputs are suddenly indicated as “connected” to the storyboard element. And right-clicking will start working again, and my custom class will appear in the drop-down list of the custom class in the Property inspector panel for the ViewController storyboard!

The other answers here are probably the most likely causes of this condition, but I felt it worth mentioning at least one other potential reason.

+3
Mar 07 '16 at 17:45
source share

Click on another view controller in the storyboard, then click on it to confirm that a new class is specified, but do not select it. Return to the new view controller that you created and you will see that it is now listed in the custom class drop-down menu. odd huh? just makes update, I think.

+2
Jul 09 '14 at 7:06
source share

I had the same problem, but none of the other solutions worked for me. The problem for me was that I had the goal of Mac and iOS, as with my versions of the same controller. For example, I had a couple of .h / .m files named FooViewController for Mac and another .h / .m couple of files named FooViewController for iOS. Each pair was correctly included in their respective goals, but for some reason Xcode did not like it, and my view controller would not appear in the Custom Class drop-down list in the storyboard view controller. In the end, I renamed my class to the iOS view controller, and it immediately appeared in the drop-down list.

+2
May 05 '16 at 4:06
source share

In my case, I drag the new TableViewController object into the storyboard, but add a new file whose subclass is "UIViewController" .... Then I add a file whose subclass is "UITableViewController", the problem is solved!

+2
Jan 01 '16 at 12:59 on
source share

I happened to encounter this problem and had no luck trying the previous sentences. Finally, I found that the header file type is set to C++ header . After changing it to C header (like all other header files), the class appears in the list. I don’t know why, though ... Perhaps it is useful for others, so I post it here.

+1
Mar 24 '15 at 16:15
source share

For those of you who are still experiencing this problem after the ViewController all around, perhaps because you clicked View instead of ViewController .

You must select the file when you click ViewController .

This solved my problem.

enter image description here

+1
Mar 01 '19 at 22:43
source share

do not add CustomViewController to any group or folder first. put it at the root of your application.

0
Feb 05 '14 at 18:47
source share

None of the above (or below :) helped me. although I found that

  • after adding a new view manager to the storyboard (just by dragging it)
  • and adding my class using the \ New \ File \ Objective-C class file, give it a name, not XIB, Next, Create

if I select my viewcontroller in the storyboard and try to assign my class to it - my class does not exist

BUT

if I click on the view that is in the control view itself, then click the drop-down menu of the class in the custom class

AND THEN

select the viewcontroller (click on the panel under the view manager), and now again click on the drop-down list of the class in the custom class that appeared in my newly added class.

strange must have been a refreshing mistake. Xcode Version 5.1 (5B130a)

0
May 27 '14 at 21:03
source share

Make sure you select the View Controller to which you want to attach your class. An easy way is to open Document Outline and select your view controller (when you click on it, the formal layout sometimes just doesn’t select the object that you had in mind).

0
Nov 30 '14 at 2:33
source share

The Storyboard looks for a custom class, but physically does not exist, and it does not display the name of the custom class in the list, nor does it display the outputs. The following solution worked fine for me.

  • Just copy the code somewhere else (say, on the desktop)
  • Open existing code.
  • Delete user class file. (Move to basket)
  • Now add the files from the copied project folder (from the desktop)
  • Remember to check the "Copy if necessary" box.
  • Open the story and bingo panel and you will get your own class files from the drop-down menu.
0
Sep 08 '15 at 12:21
source share

for my case, somehow link the resources that were deleted, so I added back and it works!

Build phases → Add build phase → Copy Bundle resources to find the file Then drag the file there

Then make sure your target membership is verified.

0
Dec 12 '15 at
source share

In my case, I chose the wrong interface, so I deleted the class file and created a new one and selected the correct parent class

0
Mar 30 '16 at 10:55
source share

I had to restart Xcode 7.3 (7D175)

0
Jun 13 '16 at 11:24
source share

What worked for me was to click on the file in the Project Navigator, then in the File Inspector, under the "Identification and Type" section, under the "Location" drop-down list, click the small folder icon, and then select the file in the pop-up window.

0
Dec 22 '16 at 22:31
source share

Try cleaning your project, and then restart your Mac. One of the features I made is to change all the names of the custom classes and re-create the project. It worked!

0
Feb 06 '17 at 13:20
source share

For macOS projects, creating a new class generates a class that inherits from NSObject instead on the NSViewController .

Vary from

 import Cocoa class AppsViewController: NSObject { } 

at

 import Cocoa class AppsViewController: NSViewController { } 
0
Sep 08 '18 at 6:43
source share

Make sure the class name of the ViewController is the name you want. those.

 class MyCustomNameViewController: UIViewController { . . } 

Changing the file name is not enough.

-one
Apr 25 '17 at 0:11
source share



All Articles