在我的应用中,我通过代码在操作表中显示UIDateTimePicker
。它工作正常。
但我不想显示日期和日期。如何做到这一点。
请帮忙。提前谢谢。
代码:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Select Date",@"Selecte Date")delegate:self cancelButtonTitle:NSLocalizedString(@"Done",@"Done")
destructiveButtonTitle:NSLocalizedString(@"Cancel",@"Cancel")
otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 50, 320, 270)];
//datePicker.showsSelectionIndicator = YES;
// datePicker.dataSource = self;
//datePicker.delegate = self;
[actionSheet addSubview:datePicker];
[datePicker release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 500)];
[actionSheet release];
答案 0 :(得分:40)
datePicker.datePickerMode = UIDatePickerModeTime;
答案 1 :(得分:5)
将datePickerMode
属性设置为以下之一:
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
答案 2 :(得分:3)
在斯威夫特:
datePicker.datePickerMode = UIDatePickerMode.Time
答案 3 :(得分:2)
datePicker.datePickerMode = UIDatePickerModeTime;