I have a custom UIAlert where I set the content view controller to my own custom VC. The alert functions properly, but I keep getting this error: "A constraint factory method was passed a nil layout anchor". I suspect it has something to do with how I am adding my subviews, but I have tried to constrain them to no avail. Here is the code:
let vc = UIViewController()
vc.preferredContentSize = CGSize(width: 250,height: 150)
let sortByPicker = UIPickerView(frame: CGRect(x: 0, y: 0, width: 250, height: 150))
sortByPicker.tag = 1
sortByPicker.delegate = self
sortByPicker.dataSource = self
vc.view.addSubview(sortByPicker)
let editRadiusAlert = UIAlertController(title: "Sort Projects By...", message: "", preferredStyle: UIAlertController.Style.alert)
editRadiusAlert.setValue(vc, forKey: "contentViewController")
editRadiusAlert.addAction(UIAlertAction(title: "Done", style: .default, handler: nil))
editRadiusAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(editRadiusAlert, animated: true)