问题
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