我在Xcode上得到一个错误说没有关于视图控制器的信息。

无法插入新的出口连接:无法找到所命名类的任何信息

为什么会这样?


当前回答

以下是一些可以解决这个问题的方法(难度依次递增):

Clean the project (Product > Clean) Manually paste in @IBOutlet weak var viewName: UIView! // or @IBAction func viewTapped(_ sender: Any) { } and control drag to it. (Change type as needed.) Also see this. Completely close Xcode and restart your project. Delete the Derived Data folder (Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.) Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)

其他回答

以下是一些可以解决这个问题的方法(难度依次递增):

Clean the project (Product > Clean) Manually paste in @IBOutlet weak var viewName: UIView! // or @IBAction func viewTapped(_ sender: Any) { } and control drag to it. (Change type as needed.) Also see this. Completely close Xcode and restart your project. Delete the Derived Data folder (Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.) Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)

这些方法对我都没用,但我确实找到了答案。

在故事板中,我复制了相应的ViewController到剪贴板中并删除了它,之后我再次粘贴它。

突然之间,一切都恢复了正常。

以下是我解决的步骤:

从视图(storyboard/xib)中删除类名引用并保存; 再次添加类名并保存; 清洁和建设;

完成了!

请只执行以下两个步骤以消除此错误。

1.  Clean Project using Product -> clean.
2.  Run the Project.

现在尝试添加/连接操作或出口。

工作很好,我很多次。

或者,如果以上都不起作用,则首先在文件中输入出口的名称@IBOutlet weak var headerHeightConstraint: NSLayoutConstraint!然后从nib中的出口单击并拖动到刚才以编程方式创建的变量。它应该可以工作,不需要任何清理、构建和删除任何东西的麻烦。