Проблема с необязательным связыванием с использованием lazy var

Я работаю с UIPageViewController и у меня есть массив viewcontroller

lazy var subviewControllers: [UIViewController] = {
    return[
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController1") as! ViewController1,
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController2") as! ViewController2,
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController3") as! ViewController3
    ]
}()

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if let subview3 = subviewControllers[2] as? ViewController3 {
        subview3.customBar.alpha = 0.8 // <- error on this line
    }
}

Но иногда у меня появляется эта ошибка, когда я делаю свиток:

Неожиданно найдено ноль при развертывании необязательного значения

0 ответов

Другие вопросы по тегам