UI 日期选择器范围.iPhone

UI Datepicker range. iPhone(UI 日期选择器范围.iPhone)
本文介绍了UI 日期选择器范围.iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a datePickerView which I want it to have a min date = current time, max date = 48hrs later. It's currently working fine, as I can't pick out of that range. But there's some aesthetic problems. Some of the period in that range is not in black. For example in the picture below, today's 7hour hand is suppose to be in black but its not.

- (void)viewDidLoad 
{

[super viewDidLoad];
NSDate *now = [[NSDate alloc] init];
NSLog(@"now is %@", now);
[datepick setDate:now animated:YES];
[now release];
datepick.minimumDate = now;

NSDate *todaysDate = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setHour:48];
NSDate *targetDate = [gregorian dateByAddingComponents:dateComponents toDate:todaysDate  options:0];
[dateComponents release];
[gregorian release];
datepick.maximumDate = targetDate;
NSLog(@"targetDate is %@", targetDate);


}

解决方案

This is default behavior when you set a minimum date and a maximum date and APPLE does it clearly to make it obvious that they are not selectable.

What you can do is implement a UIPickerView for the dates and implement viewForRow for the pickerView methods.

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* tView = (UILabel*)view;
if (!tView){
    tView = [[UILabel alloc] init];

    // Add label.text which is the picker value for the row (for that component)

    // set the font for the label as black.

}

You can also change the font size of the values in the pickerView.

这篇关于UI 日期选择器范围.iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)