0

我想问为什么我的自定义视图没有显示在 viewController 中的 override loadView() 中。它只是空白,我的设置有什么问题吗?在这里,我向您展示我的设置

// This is inside my custom UIView
lazy var contentViewSize = CGSize(width: self.frame.width, height: self.frame.height + 100)

    lazy var scrollView: UIScrollView = {
        let scrollView = UIScrollView(frame: .zero)
        scrollView.frame = self.bounds
        scrollView.contentSize = contentViewSize
        scrollView.backgroundColor = .white
        return scrollView
    }()

    lazy var contentView: UIView = {
        let view = UIView()
        view.frame.size = contentViewSize
        view.backgroundColor = #colorLiteral(red: 0.9560143352, green: 0.9656195045, blue: 0.9688490033, alpha: 1)
        return view
    }()

    let navigationView      = UIView(color: .white)
    let profileImage        = UIImageView(image: #imageLiteral(resourceName: "ic-tab-profile"), renderingMode: .alwaysTemplate)
    let profileLbl          = GProfileLbl(name: "Profile Name".localized(), fontSize: 27, color: #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1))
    let schoolSelectionBtn  = GTSelecSchoolBtn(type: .system)
    let progressView        = ProgressView()
    let infoBtn             = GTProfileBtn(name: "Basic Info")
    let changePasswordBtn   = GTProfileBtn(name: "Change Password")
    let helpBtn             = GTProfileBtn(name: "Help")
    let termAndConditionBtn = GTProfileBtn(name: "Term and conditions")
    let privacyBtn          = GTProfileBtn(name: "Privacy")
    let signOutBtn: UIButton = {
        let btn = UIButton(type: .system)
        let attributeString = NSAttributedString(string: "Sign Out", attributes: [NSAttributedString.Key.foregroundColor: #colorLiteral(red: 0.9215686275, green: 0.3411764706, blue: 0.3411764706, alpha: 1), NSAttributedString.Key.font: UIFont(name: "NunitoSans-SemiBold", size: 14)])
        btn.setAttributedTitle(attributeString, for: .normal)
        return btn
    }()

    let progressHUD = JGProgressHUD(style: .dark)

    var infos: InfoResult?
    var schools  = [SchoolList]()
    var progress: ProgressStatus?

    override init(frame: CGRect) {
        super.init(frame: .zero)
        backgroundColor = .white
        setupScrollView()
        configure()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

// this is in my UIViewController
lazy private(set) var profileView = ProfileView()

    override func loadView() {
        view = profileView
    }

    override func viewDidLoad() {
        super.viewDidLoad()        
        setupNavigation()
    }

你能告诉我我的视图在哪里没有加载吗?我在标签中使用自动布局,是因为这个吗?

4

0 回答 0