“Could not find any information for class named ViewController”

后端 未结 30 1816
南方客
南方客 2020-12-02 06:35

This bug has been driving me nuts since I started using Xcode (4.6.3). Whenever I try to link a Storyboard item to my code, I get the error:

Could not

相关标签:
30条回答
  • 2020-12-02 07:18

    Select the ViewController in storyBoard, delete current value in Right hand panel/"Customer class"/"class" then re-add control class (type: "SampleViewController"...), enter. --> That work for me

    0 讨论(0)
  • 2020-12-02 07:18

    Delete the files (only the references) and add the files again.

    0 讨论(0)
  • 2020-12-02 07:19

    This worked for me:

    1. Perform 'Clean build folder'
      (press and hold the 'option' key and go to the "Product" menu to access it.
    2. Perform a simple "Clean" (CMD-SHIFT-K) from the "Product" menu.
    3. Build the project to let Xcode compile the files. Also, let it index files if necessary.

    On a side note, I am not sure if this helped but I also deleted the Derived data before performing the above steps (Xcode preferences > Locations)

    0 讨论(0)
  • 2020-12-02 07:19

    As I commented on @ChrisHarrison's answer, those things did not work for me, but deleting the derived data as in I got it to work by deleting the derived data as in https://stackoverflow.com/a/16182672/1449799

    0 讨论(0)
  • 2020-12-02 07:20

    I would try to remake the .m and .h files in question and give them an original name, not generic like "ViewController". Try something more along the lines of what you want that file to do, and ending in View Controller (i.e. "PizzaDecoraterViewController")

    Then select the ViewController that you want to connect to those files. Make sure that you select the ViewController, not just an object within. Click the black bar at the bottom (the one that has the "First Responder" and "Exit" icons). The entire ViewController should outline blue. Then go to the Custom Class section in the Identity Inspector and you should see a grayed out "UIViewController" in the first field. In that field, type in the name of the .h or .m file that you want it to connect to (Start typing PizzaDecorator... and it should do a little auto-complete thing). Then hit ENTER.

    When you open up the Assistant Editor, make sure that the file that you are trying to drag and drop to is, in fact, the correct file.

    If you have done all as said above, then it should work.

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

    Usually when this happens to me I just haven't saved the code for the class yet. Just hop over to the code and hit cmd+s and it often fixes the problem right way.

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