Reputation: 156
My code runs successfully on iOS12.1, but recently when I update the version of iOS, Xcode, macOS to iOS12.2 Xcode10.2 and macOS10.14.4, there is something wrong in my project. There is no problem with my app interface, but when I open the action sheet, it tells me that my constraints are conflicting. How can I solve it? this is my UI this is the warning in Xcode
I reset the constraints of the interface, but no matter how I get it, I still have the same problem.
Those are my codes, once I tap the button, the action sheet occurred, and Xcode tells me that my constraints are conflicting
@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)
}
I except there is no warning of the conflicting constraints.
Upvotes: 2
Views: 880
Reputation: 11537
You may have to manually silent the constraint alert.
@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
}
Upvotes: 4