禁用/启用UIDatepicker [英] Disable / Enable UIDatepicker
问题描述
Xcode中是否有任何禁用/启用功能,我已经尝试过隐藏功能,但这确实不符合我的需求.我正在尝试关闭uiswitch,如果未切换,请关闭我的UIDatepicker,我希望它显示出来.隐藏该日期仍会将今天的日期输出到我的邮件编辑器.反正有这样做吗?
Is there any disable/enable function in Xcode, i have already tried the hidden function but that really doesn't suit my needs. I'm trying to turn off my UIDatepicker if a uiswitch has been toggled and if it isn't toggled i want it shown. hiding this still outputs todays date to my mail composer. Is there anyway to do this?
推荐答案
确保.h文件中具有UIDatepicker的属性(IBOutlet).那么您可以简单地这样做:
Make sure you have a property (IBOutlet) for your UIDatepicker in your .h file then you can simply do like this:
DatePickerNamed.userInteractionEnabled = YES;
DatePickerName.userInteractionEnabled = NO;
此外,如果我禁用了按钮和开关,我还会降低其alpha值,因此还会有视觉反馈表明它们处于非活动状态.
In addition to that I also turn down the alpha value for buttons and switches, if I disable them, so there is also a visual feedback that they're inactive.
这篇关于禁用/启用UIDatepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!