I'm trying to put a UIPickerView
in a UIAlertView
however I can't seem to size it correctly. Here's what I'm getting:
Here's my code:
let alertView = UIAlertController(title: "Select item from list", message: "", preferredStyle: UIAlertControllerStyle.alert)
let pickerView = UIPickerView(frame: CGRect(x: 0, y: 0, width: 250, height: 60))
pickerView.dataSource = self
pickerView.delegate = self
alertView.view.addSubview(pickerView)
let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)
alertView.addAction(action)
parent.present(alertView, animated: true, completion: nil)
The trick is:
adjust the size of the new view when the alert view is presented