日期范围选择公用函数,传参为选择的textField
来源:互联网 发布:人工智能是什么东西 编辑:程序博客网 时间:2024/06/05 09:06
- (void)viewDidLoad
{
[superviewDidLoad];
//初始日期
beginDateTextField_ = [ [UITextField alloc ]init ];
beginDateTextField_.frame =CGRectMake( newPoint.x , newPoint.y , dudaoTextFieldWidth , dudaoTextFieldHeight );
beginDateTextField_.borderStyle =UITextBorderStyleRoundedRect;
beginDateTextField_.font =[UIFont fontWithName:@"Helvetica" size:16 ];
beginDateTextField_.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter;
//文本输入框添加按钮
beginDateButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
[ beginDateButtonsetImage: buttonImage forState: UIControlStateNormal ];
[ beginDateButton addTarget: self
action: @selector(selectButton:)
forControlEvents:UIControlEventTouchUpInside ];
beginDateTextField_.rightViewMode =UITextFieldViewModeAlways;
beginDateTextField_.rightView =beginDateButton;
beginDateTextField_.delegate =self;
[ self.viewaddSubview: beginDateTextField_ ];
//初始化存放选择的textfield
selectedTextField = [ [ UITextField alloc ] init ];
}
//************优化日期选择代码***************//
//显示日期选择
- (void)dateButtonDidPush
{
//设置完成按钮
UIBarButtonItem* beginDoneButton =
[ [ [ UIBarButtonItem alloc ]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target: self
action: @selector(doneDidPush) ]autorelease ];
[ selfsetToolbarItems: [ NSArrayarrayWithObject: beginDoneButton ] animated:YES ];
[ UIViewbeginAnimations: nilcontext: nil ];
[ UIViewsetAnimationDuration: 0.3 ];
//时间选择器上移
datePicker_.frame =CGRectMake( 0 , 216 , 320 , 216 );
//工具条上移
CGRect toolbarFrame = self.navigationController.toolbar.frame;
toolbarFrame.origin.y =self.view.frame.size.height - toolbarFrame.size.height -50 ;
self.navigationController.toolbar.frame = toolbarFrame;
[ UIViewcommitAnimations ];
}
//日期选择完成按钮
- (void)doneDidPush
{
NSDate* date = [ datePicker_date ];
NSDateFormatter* dateFormatter = [ [ NSDateFormatter alloc ] init ];
[ dateFormatter setDateFormat: @"yyyy-MM-dd" ];;
selectedTextField.text = [ dateFormatterstringFromDate: date ];
[ UIViewbeginAnimations: nilcontext: nil ];
[ UIViewsetAnimationDuration: 0.3 ];
//隐藏工具条
CGRect toolbarFrame = self.navigationController.toolbar.frame;
toolbarFrame.origin.y =
self.view.bounds.size.height +65 ;
self.navigationController.toolbar.frame = toolbarFrame;
//隐藏完成按钮
UIBarButtonItem* spaceButton = [ [ [ UIBarButtonItem alloc ]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action: nil ]autorelease ];
[ selfsetToolbarItems: [ NSArrayarrayWithObject: spaceButton ] animated:YES ];
//隐藏日期选择器
datePicker_.frame = toolbarFrame;
[ UIViewcommitAnimations ];
}
//判断是那一个textfield中按钮,并把相应textfield传给 selectedTextField
- (void)selectButton:(UIButton*)button
{
if ( button == beginDateButton )
{
selectedTextField =beginDateTextField_;
}
else
{
selectedTextField =endDateTextField_;
}
[ selfdateButtonDidPush ];
}
//***************************************//
- 日期范围选择公用函数,传参为选择的textField
- 日期范围选择模块
- 公用的选择dialog
- Bootstrap的DatePicker日期范围选择
- 设置日期选择组件(DateField )的选择范围
- 设置日期选择组件(DateField )的选择范围
- 设置日期选择组件(DateField )的选择范围
- android开发时为日期控件设置选择范围,再次点击时显示上次选择日期
- 选择日期范围,同时要判断选择的开始日期和结束日期的选择是否正确
- Flex 实现日期范围的选择并格式化
- bootstrap-daterangepicker:最好用的日期范围选择组件
- 选择时间框为从上个月日期到这个月当前日期范围
- mysql日期选择函数
- 自定义时间选择器的分钟为自定义的选择范围
- EXTJS自定义验证日期选择范围
- Android DatePicker 限制日期选择范围
- easyui-datebox限制选择日期范围
- Html5添加用户选择一个日期时间范围的日期选择器插件教程
- CollectionUtils select方法 详解 用途~~~
- HTML嵌套规则
- oracle改变字符编码(ORA-12899问题)
- vi/vim 常用命令
- JEECG
- 日期范围选择公用函数,传参为选择的textField
- C# 调用Windows API(1)
- 多线程实例之简单的卖票程序 ------记录与毕向东老师视频
- redis 集群设计一种方案
- Maven(一)Maven及插件安装
- PB编程框架、PB经典界面、PB开发平台
- C#调用Windows API(2)
- 可视化代码评审工具 —— Phabricator
- 拉近用户体验的距离