LoginSignup
1
1

More than 3 years have passed since last update.

【Swift】Compact状態のDatePickerに戻る処理を行う

Last updated at Posted at 2021-02-21

新しいDatePicker

iOS14からどうやらDatePickerの挙動が変わったらしく、今までのドラムロール式の日付・日時選択からカレンダー表示の様な選択方法が選べるようになりました(従来のDatePickerも引き続き使用出来る)。
しかしこのポップアップされるDatePickerは日付を選択時に一つ前に戻る機能が備わって居らず自分で書いて選択時に戻る処理を入れてあげる必要がある。
CompactDatePickerが表示されたiPhoneSimulator

コード

ViewController
@IBAction func CompactDatePicker(_ sender: UIDatePicker) {
    // 日付選択時に選択前の画面に戻る
    self.dismiss(animated: true, completion: nil)
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1