如何仅在iOS中使用DatePicker接受Month和Year [英] How to accept only Month and Year using DatePicker in iOS

查看:198
本文介绍了如何仅在iOS中使用DatePicker接受Month和Year的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用swift构建应用程序,在该应用程序中有一个字段用于接收借记卡到期付款的到期日期。在Swift中使用DatePicker,我如何只接受月份和年份。



如果不可能使用datepicker,那么请另行建议。



提前谢谢。 / p>

解决方案

Choice-1



strong> Objective-C

  yourDatepicker.datePickerMode = UIDatePickerModeDate; 

Swift

  yourDatepicker.datePickerMode = UIDatePickerMode.Date 

Swift3

  yourDatepicker.datePickerMode = .date 

另一种模式是




  • UIDatePickerModeTime,

  • UIDatePickerModeDate
  • UIDatePickerModeDateAndTime,

  • UIDatePickerModeCountDownTimer



选择2



上述方法不能正常运行,然后检查链接


I am building an app using swift and in that app there is one field for accepting expiry date for Debit card for payment purpose. How can I accept only month and year by using DatePicker in Swift.

If it is not possible using datepicker then please suggest any another way.

Thank you in advance.

解决方案

Choice-1

Objective-C

yourDatepicker.datePickerMode = UIDatePickerModeDate;

Swift

 yourDatepicker.datePickerMode = UIDatePickerMode.Date

Swift3

yourDatepicker.datePickerMode = .date

the another modes are

  • UIDatePickerModeTime,
  • UIDatePickerModeDate,
  • UIDatePickerModeDateAndTime,
  • UIDatePickerModeCountDownTimer

Choice-2

the above method not working well, then check this link

这篇关于如何仅在iOS中使用DatePicker接受Month和Year的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆