swift iOS 中带有 uipickerview 的 uialertcontroller?

uialertcontroller with uipickerview in swift iOS?

我想在 UIAlertController 中显示 UIPickerView。我成功了,但是警报视图的显示是错误的。下面是警报视图代码。

let alertView = UIAlertController(title: "Select Launguage", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet);
alertView.modalInPopover = true;
alertView.view.addSubview(pickerView)
let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
alertView.addAction(action)
presentViewController(alertView, animated: true, completion: nil)

选择器视图代码如下;

var pickerView = UIPickerView();
self.pickerView.delegate = self
self.pickerView.dataSource = self

"OK" 按钮,警报标题和选择器视图重叠。现在请帮我怎么做。

通过 message 参数插入新行以创建更多垂直 space。

let alertView = UIAlertController(title: "Select Language", message: "\n\n\n\n\n", preferredStyle: UIAlertControllerStyle.ActionSheet);

为了更好地控制选择器视图位置,请使用 UIPickerView(frame:) 创建 UIPickerView 实例,并且您必须将选择器视图添加到警报控制器的子视图中。