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

后端 未结 25 1078
北荒
北荒 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:27

    for my case, somehow bundle resources got deleted, so I added back and worked!

    Build Phases -> Add Build Phase -> Copy Bundle Resources find your file Then drag and drop your file there

    Then make sure your target membership is checked.

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

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

    1. Right-click your My.storyboard entry in the Project Navigator panel and select the Open As->SourceCode menu choice. Find your view controller entry in the XML, and add the attribute customClass="MyController".

    2. Save the storyboard.

    3. Right-click your My.storyboard entry in the Project Navigator panel again, and select the Open As->Interface Builder - Storyboard menu choice.

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

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

    none of the above(or below :) helped me. though I found that

    1. after adding new viewcontroller to storyboard (just by dragging it in)
    2. and adding my class by File\New\File\Objective-C Class, give it a name, no XIB, Next, Create

    if I select my viewcontroller in storyboard and try to assign my class to it - my class is not there

    BUT

    if I click on a view that is in the viewcontroller itself then click on a class dropdown menu in Custom Class

    AND THEN

    select viewcontroller (click on a bar below the viewcontroller) and now again click on a class dropdown in Custom Class my newly added class magically shows up.

    weird, must be a bug with refreshing. Xcode Version 5.1 (5B130a)

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

    Two ways I found that solve the problem but they are work arounds. 1. Just type the view controllers name in the text field, or 2. close the project and then reopen it and in the project initialization it places the file on the list.

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

    Make sure your class inherits from UIViewController.

    @interface ClassName : UIViewController
    
    0 讨论(0)
  • 2020-12-08 02:30

    What worked for me was, click on the file in the Project Navigator, then, in the File Inspector under "Identity and Type" beneath the "Location" dropdown box, click on the little folder icon and then select the file in the popup window.

    0 讨论(0)
提交回复
热议问题