我正在使用 UIPageViewController 并且我有一组视图控制器
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
}
}
但有时我在滚动时会遇到这个错误:
在展开可选值时意外发现 nil