有没有办法从UIAlertControllerStyle.ActionSheet呈现日期选择器?有办法在ActionSheet中添加按钮并向这些按钮添加操作,但我找不到在ActionSheet中添加datepicker或任何自定义视图的解决方案. 这是不
class KPDatePickerViewController: UIViewController { var datePicker:UIDatePicker! @IBOutlet var dateTextField:UITextField! override func viewDidLoad() { var customView:UIView = UIView (frame: CGRectMake(0, 100, 320, 160)) customView.backgroundColor = UIColor.brownColor() datePicker = UIDatePicker(frame: CGRectMake(0, 0, 320, 160)) customView .addSubview(datePicker) dateTextField.inputView = customView var doneButton:UIButton = UIButton (frame: CGRectMake(100, 100, 100, 44)) doneButton.setTitle("Done", forState: UIControlState.Normal) doneButton.addTarget(self, action: "datePickerSelected", forControlEvents: UIControlEvents.TouchUpInside) doneButton.backgroundColor = UIColor .blueColor() dateTextField.inputAccessoryView = doneButton } func datePickerSelected() { dateTextField.text = datePicker.date.description } }