1
我創建了自己滑出導航菜單,但致命的錯誤,當我點擊一個鏈接菜單上很多,它會導致一個錯誤:view.removeFromSuperview()在很多水龍頭
fatal error: unexpectedly found nil while unwrapping an Optional value
這是對的滑動屏幕動畫:
func animateLeftPanel(shouldExpand shouldExpand: Bool) {
if (shouldExpand) {
currentState = .LeftPanelExpanded
animateCenterPanelXPosition(targetPosition: CGRectGetWidth(centerNavigationController.view.frame) - centerPanelExpandedOffset)
} else {
animateCenterPanelXPosition(targetPosition: 0) { finished in
self.currentState = .BothCollapsed
self.leftViewController!.view.removeFromSuperview()
self.leftViewController = nil;
}
}
}
在self.leftViewController!.view.removeFromSuperview()
行了,我不明白爲什麼我得到這個錯誤,以及如何解決它。
測試'self.leftViewController'是否已經是零而不是使用強制'!'? –
@PhillipMills它不是零,我不明白,如果我點擊一次它的工作原理,但如果我點擊很多物品它會崩潰 – Ben
@PhillipMills我剛剛刪除了它看起來工作的線 – Ben