Time Picker in UIAlertView

谁说我不能喝 提交于 2019-12-11 01:53:37

问题


I'm in need of a popup that asks for a time input, I figured an alertview would be the way to go but I have no idea where to begin embedding a time picker into an alertview.

Unless there is a better way of doing this?


回答1:


For anybody else, I adapted the question in the comments to be a time picker like so:

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)



回答2:


You can use this component for the alert feel with both date and time picker

https://github.com/palKaran/UIAlertDateTimePicker



来源:https://stackoverflow.com/questions/42949529/time-picker-in-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!