xcode 使用未声明的类型 UIViewController

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40875167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:36:54  来源:igfitidea点击:

use of undeclared type UIViewController

iosswiftxcode

提问by dgelinas21

I have not changed anything major in this swift file, yet for some reason when I went to run my app I got a new error stating "Use of undeclared type UIViewController" in the first line of my swift file. I have tried cleaning and checking the targets, but am unable to figure out the issue.

我没有更改此 swift 文件中的任何主要内容,但出于某种原因,当我去运行我的应用程序时,我在 swift 文件的第一行收到一个新错误,指出“使用未声明的类型 UIViewController”。我曾尝试清理和检查目标,但无法找出问题所在。

I am getting an errors on every line below, excluding the import statements

我在下面的每一行都收到错误消息,不包括导入语句

import Foundation
import FirebaseAuth
import FirebaseDatabase    

public class User: UIViewController {
        @IBOutlet weak var _Fname: UITextField!
        @IBOutlet weak var _Lname: UITextField!
        @IBOutlet weak var _Email: UITextField!
        @IBOutlet weak var _Password1: UITextField!
        @IBOutlet weak var _Password2: UITextField!

Please let me know if you have any thoughts on why this may be occurring. Thanks in advance!

如果您对为什么会发生这种情况有任何想法,请告诉我。提前致谢!

回答by unniverzal

You probably forgot to import UIKiton top of your file. Without UIKitimported, your object doesn't know what a UIViewControlleris.

你可能忘记了import UIKit在你的文件之上。如果没有UIKit导入,您的对象不知道 aUIViewController是什么。