iPad上的空白UIDatePicker处于模式UIDatePickerModeDateAndTime [英] blank UIDatePicker on iPad in mode UIDatePickerModeDateAndTime

查看:174
本文介绍了iPad上的空白UIDatePicker处于模式UIDatePickerModeDateAndTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用iPad上的UIDatePicker。 setDate或.date赋值使DatePicker为空:

I am struggling with the UIDatePicker on iPad. The setDate or .date assignment makes the DatePicker empty:

    UIDatePicker * dtVCpicker = [[UIDatePicker alloc] initWithFrame:CGRectZero]; 
    dtVCpicker.datePickerMode = UIDatePickerModeDateAndTime;
    dtVCpicker.date = [NSDate date];
    dtVCpicker.minimumDate = [NSDate date];
[self.view.window addSubview:dtVCpicker];

如果我将模式更改为UIDatePickerModeDate或UIDatePickerModeTime则看起来很正常。

if I change the mode to UIDatePickerModeDate or UIDatePickerModeTime then it would look normal.

非常感谢您的回答!

推荐答案

我为此问题实施了解决方法:在viewDidLoad中设置dtVCpicker.date使得Picker可显示。

I implemented the work-around for this issue: setting the dtVCpicker.date inside the viewDidLoad made the Picker displayable.

在我现有的代码中,我刚刚在Popup中添加了选择器,因此当Popup显示时没有调用viewDidLoad。所以我创建了一个包含选择器的视图,并将视图放在Popup中(并将setDate放在viewDidLoad中)。它有效。

In my existing code, I just added the picker inside a Popup, and so viewDidLoad wasn't called when the Popup displays. So I created a view that contains the picker, and put the view inside the Popup (and put the setDate in the viewDidLoad). It works.

这篇关于iPad上的空白UIDatePicker处于模式UIDatePickerModeDateAndTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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