應用崩潰後震落XCODE 9和迅速4.同時在應用升級的項目之後,更新代碼的xcode 9和迅速4
backview.addsubview(stackview)
應用調試與的libC++ abi.dylib崩潰:終止與未捕獲類型爲NSException的異常。代碼在swift 3中運行完美。但是在遷移到swift 4後,它崩潰了。這是我的全部功能。
var isAlreadyThere = false
if let audioView = self.view.subviews.filter (
{ $0.tag == 123456}).first {
audioView.tag = 123456
isAlreadyThere = true
}
if isAlreadyThere {
return
}
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
let backView = UIVisualEffectView(effect: blurEffect)
backView.tag = 123456
backView.frame = CGRect(x: 0, y: self.view.frame.height+35 , width: self.view.frame.width, height: 40)
backView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(backView)
pauseButton = UIButton(type: .custom)
pauseButton.titleLabel?.font = Util.getFontSize()
pauseButton.setTitle("Pause", for: .normal)
pauseButton.setTitleColor(UIColor.black, for: .normal)
pauseButton.addTarget(self, action: #selector(pausePressed(_:)), for: .touchDown)
durationLabel = UILabel()
durationLabel.textColor = UIColor.black
durationLabel.font = Util.getFontSize()
durationLabel.textAlignment = .center
durationLabel.text = "0:00"
stopButton = UIButton(type: .custom)
stopButton.titleLabel?.font = Util.getFontSize()
stopButton.setTitle("Stop", for: .normal)
stopButton.setTitleColor(UIColor.black, for: .normal)
stopButton.addTarget(self, action: #selector(stopPressed(_:)), for: .touchDown)
let stackView = UIStackView(frame: CGRect(x: 0, y:0 , width: backView.frame.width, height: 40))
stackView.alignment = .fill
stackView.axis = .horizontal
stackView.distribution = .fillEqually
stackView.spacing = 5
stackView.addArrangedSubview(pauseButton)
stackView.addArrangedSubview(durationLabel)
stackView.addArrangedSubview(stopButton)
backView.addSubview(stackView)
if audioViewYposition == nil {
audioViewYposition = self.view.frame.height - 40
}
UIView.animate(withDuration: 0.2, delay: 0.1, options: .curveEaseInOut, animations: {
backView.frame.origin.y = self.audioViewYposition
}, completion: nil)
嘗試添加異常斷點並查看崩潰發生的位置。 –