ios - 如何在按钮单击时隐藏/显示日期选择器?
<p><p>我有一个 UIDatePicker,我想在 UIButton Click 上隐藏和显示。</p>
<p>为此,我使用 BOOL 变量 isTouchFirst。但它会在按钮的第二个事件中隐藏和显示。</p>
<p>请解决此问题。并首先检查它是否适用于双击事件。</p>
<pre><code>if(isTouchFirst){
isTouchFirst=NO;
self. DatePicker.hidden=NO;
NSDateFormatter *dateFormatter = [ init];
;
_DatePicker.datePickerMode = UIDatePickerModeDate;
formatedDate=[init];
formatedDate = ;
self.SelectedDate.text =formatedDate;
];
_goDateForcustmoeDetail=formatedDate;
}
else {
isTouchFirst=YES;
self. DatePicker.hidden=YES;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>BOOL datePickerHidden;
- (void)viewDidLoad
{
;
datePickerHidden = YES;
// _datePicker = [UIDatePicker alloc...
;
// UIButton *dateHiddenSwitchBtn = [UIButton alloc...
dateHiddenSwitchBtn addTarget:self action:@selector(switchDatePickerHidden) forControlEvents:UIControlEventTouchUpInside];
;
}
- (void)switchDatePickerHidden
{
if (datePickerHidden) datePickerHidden = NO;
else datePickerHidden = YES;
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何在按钮单击时隐藏/显示日期选择器?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/33450255/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/33450255/
</a>
</p>
页:
[1]