gpt4 book ai didi

ios - 在 swift iOS 中使用 uipickerview 的 uialertcontroller?

转载 作者:行者123 更新时间:2023-11-28 13:03:01 25 4
gpt4 key购买 nike

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

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)

选择器 View 代码如下;

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

enter image description here

“确定”按钮,警报和选择器 View 的标题重叠。现在请帮我怎么做。

最佳答案

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

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

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

关于ios - 在 swift iOS 中使用 uipickerview 的 uialertcontroller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com