我的代码在iOS12.1上成功运行,但是最近当我将iOS,Xcode,macOS的版本更新为iOS12.2 Xcode10.2和macOS10.14.4时,我的项目出现了问题。 我的应用程序界面没有问题,但是当我打开操作表时,它告诉我约束相互冲突。 我该如何解决? this is my UI this is the warning in Xcode
我重置了接口的约束,但是无论如何获取,我仍然遇到相同的问题。
这些就是我的代码,一旦我点击按钮,就会出现操作表,而Xcode告诉我约束是冲突的
@IBAction func newToDoBarButtonTapped(_ sender: UIBarButtonItem) {
let alertController = UIAlertController(title: "New or Edit", message: nil, preferredStyle: .actionSheet)
let newToDoAlertAction = UIAlertAction(title: "New Item", style: .default, handler: {(_) in
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let registerVC = mainStoryboard.instantiateViewController(withIdentifier: "NewToDoStoryboard") as! ToDoViewController
self.navigationController?.pushViewController(registerVC, animated: true)
})
let editInformationOfListAction = UIAlertAction(title: "Edit Information", style: .default, handler: {(_) in
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let registerVC = mainStoryboard.instantiateViewController(withIdentifier: "EditStoryboard") as! EditItemTableViewController
self.navigationController?.pushViewController(registerVC, animated: true)
})
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(newToDoAlertAction)
alertController.addAction(editInformationOfListAction)
alertController.addAction(cancelAction)
self.present(alertController,animated: true,completion: nil)
}
我除了没有约束冲突的警告。
答案 0 :(得分:0)
您可能必须手动使约束警报静音。
@IBAction func newToDoBarButtonTapped(_ sender: UIBarButtonItem) {
...
self.present(alertController,animated: true,completion: nil)
alertController.view.subviews.flatMap({$0.constraints}).filter{ (one: NSLayoutConstraint)-> (Bool) in
return (one.constant < 0) && (one.secondItem == nil) && (one.firstAttribute == .width)
}.first?.isActive = false
}