Disable Past Date in UIDatePicker in IPhone Objective C

前端 未结 3 456
春和景丽
春和景丽 2021-02-05 00:29

I am new to Objective C and IPhone development.

I am using a UIDatePicker in my IPhone Application and my requirement is to allow the user to choose the future date only

3条回答
  •  一整个雨季
    2021-02-05 00:40

    For Swift :

    let todaysDate = Date()
    
    datePicker.minimumDate = todaysDate
    

    It will not let the user to pick a date older than Today

    OR

    Or, if you want to reduce the code, use following way:

    datePicker.minimumDate = Date()
    

提交回复
热议问题