1
呼叫解鎖裝置沒有工作,那麼打印「unlockCalled」了很多次,然後給出了這樣的錯誤:activityIndicators和UIApplication.sharedApplication()
2016-03-27 14:20:45.976 xxx[1002:57886] -[UIApplication endIgnoringInteractionEvents] called without matching -beginIgnoringInteractionEvents. Ignoring.
我要去哪裏錯了?
var activityIndicator = UIActivityIndicatorView()
func lockDevice(){print("lockCalled")
activityIndicator = UIActivityIndicatorView(frame: self.view.frame)
activityIndicator.backgroundColor = UIColor(white: 1.0, alpha: 0.5)
activityIndicator.center = self.view.center
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(activityIndicator)
activityIndicator.startAnimating()
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
}
func unlockDevice(){
print("unlockCalled")
activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
}
好了,該錯誤信息是不言自明...其中(何時),你調用這些函數? – Alladinian
我lockDevice()然後檢索數據從網絡中像5-6秒,然後我unlockDevice()但activityIndicator不會消失,它仍然會忽略我的事件@阿拉迪尼亞 –
您可以設置一個斷點在回調檢查問題。另外,確保在主線程上調用'unlockDevice()'。 – Alladinian