“Could not find any information for class named ViewController”

后端 未结 30 1815
南方客
南方客 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:11

    For me removing them from your target membership in the right column and adding them again did the trick

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

    This is the EASIEST step that I did to fix this problem.

    1. I clean the project
    2. Drag a new button in the view controller.
    3. Build the project.
    4. Connect the newly dragged the button to the class (either outlet or action).
    5. Then voila!!! Other outlets can now be connected to the class again!
    0 讨论(0)
  • 2020-12-02 07:12

    Well in my case, the thing that worked (it's a litle weird, but worked) is the following:

    Try to add a datasource (ex. an extension to the ViewController like a UITableViewDataSource). Xcode will try to reload the ViewController. Then I wrote some method of the protocol (in the beginning Xcode did not autocomplete the methods, but wrote it out manually), then I added the IBOutlets, and then lastly, I removed the datasource.

    Example:

    class TestViewController:UIViewController{
        // This viewController presents “Could not find any information for  class named ViewController”
    }
    
    extension TestViewController:UITableViewDataSource{
        //Add Some methods of the protocol, Xcode will try to autocomplete and then it's going to reload the class, from then you can add your IBOulets / Actions .. And remove this extension if you don't need it otherwise.
    }
    
    0 讨论(0)
  • 2020-12-02 07:13

    I tried all of these answers, the problem for me was related to Xcode not being able to index the files. I fixed this by simply quitting Xcode and reopening the project. Of course I did that after trying all of the above solutions :p

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

    What worked for me was, instead of dragging the connection from the button to the code, was:

    1. Clicking the desired storyboard item.
    2. Opening the connection inspector (right panel)
    3. Dragging from the + circle to the area of code. Like so:

    after I linked my code in this way, it worked normally from thereafter.

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

    As my testing experience,if you delete a class which was associated in the Xcode,and than add file again,than this issue will occur.

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