Неразрешенная ошибка в AppDelegate о mainView (xcode11) - PullRequest
0 голосов
/ 05 июля 2019

Я пытаюсь создать собственное приложение для управления временем, и в моем AppDelegate.swift появилась следующая ошибка.

Я уже пытался найти орфографические ошибки или другие ошибки в моем коде, но безуспешно.

Должно быть основной ошибкой Use of unresolved Identifier, но каким-то образом я не могу найти решение.

Первый вопрос здесь ^^ Дайте мне знать, когда вам понадобится дополнительная информация.Спасибо за помощь!

import UIKit

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        self.window = UIWindow(frame: UIScreen.main.bounds)

        if let window = self.window {
            window.backgroundColor = UIColor.white

            let nav = UINavigationController()
            let mainView = ViewController()
            nav.viewControllers = [mainView]

            window.rootViewController = nav
            window.makeKeyAndVisible()
        }

        return true
    }
    .
    .
    .
    // Other default AppDelegate functions
}

Use of unresolved identifier 'ViewController'

РЕДАКТИРОВАТЬ: Код ViewController

import UIKit

enum MyTheme {
    case light
    case dark
}

class ViewController: UIViewController {

    var theme = MyTheme.dark

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "My Calender"
        self.navigationController?.navigationBar.isTranslucent=false
        self.view.backgroundColor=Style.bgColor
        view.addSubview(calenderView)
        calenderView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10).isActive=true
        calenderView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -12).isActive=true
        calenderView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 12).isActive=true
        calenderView.heightAnchor.constraint(equalToConstant: 365).isActive=true

        let rightBarBtn = UIBarButtonItem(title: "Light", style: .plain, target: self, action:
        #selector(rightBarBtnAction))
        self.navigationItem.rightBarButtonItem = rightBarBtn
    }

    override func viewWillLayoutSubviews() {

        super.viewWillLayoutSubviews()
        calenderView.myCollectionView.collectionViewLayout.invalidateLayout()
    }

    @objc func rightBarBtnAction(sender: UIBarButtonItem) {

        if theme == .dark {
            sender.title = "Dark"
            theme = .light
            Style.themeLight()
        } else {
            sender.title = "Light"
            theme = .dark
            Style.themeDark()
        }

        self.view.backgroundColor=Style.bgColor
        calenderView.changeTheme()
    }

    let calenderView: CalenderView = {
        let v=CalenderView(theme: MyTheme.dark)
        v.translatesAutoresizingMaskIntoConstraints=false
        return v
    }()
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...