我需要一个要求输入时间的弹出窗口,我认为警报 View 是可行的方法,但我不知道从哪里开始将时间选择器嵌入到警报 View 中。
除非有更好的方法吗?
最佳答案
对于其他人,我将评论中的问题改编为时间选择器,如下所示:
let vc = UIViewController()
vc.preferredContentSize = CGSize(width: 250,height: 300)
let pickerView = UIDatePicker(frame: CGRect(x: 0, y: 0, width: 250, height: 300))
vc.view.addSubview(pickerView)
let editRadiusAlert = UIAlertController(title: "Choose ETA", message: "", preferredStyle: UIAlertControllerStyle.alert)
editRadiusAlert.setValue(vc, forKey: "contentViewController")
editRadiusAlert.addAction(UIAlertAction(title: "Set ETA", style: .default, handler: nil))
editRadiusAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(editRadiusAlert, animated: true)
关于swift3 - UIAlertView 中的时间选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42949529/