日期选择代码,使用datepicker
来源:互联网 发布:海口seo公司 编辑:程序博客网 时间:2024/06/08 20:15
日期选择代码,使用datepicker
- (void)viewDidLoad
{
[super viewDidLoad];
//日期
lessonDateTextField_ = [ [ UITextField alloc ] init ];
lessonDateTextField_.frame = CGRectMake( newPoint.x , newPoint.y , dudaoTextFieldWidth , dudaoTextFieldHeight );
lessonDateTextField_.borderStyle = UITextBorderStyleRoundedRect;
lessonDateTextField_.font =[ UIFont fontWithName: @"Noteworthy-Light" size: 18 ];
//文本输入框添加按钮
UIButton* lessonDateButton = [ UIButton buttonWithType: UIButtonTypeDetailDisclosure ];
[ lessonDateButton setImage: buttonImage forState: UIControlStateNormal ];
[ lessonDateButton addTarget: self
action: @selector(lessonDateButtonDidPush)
forControlEvents: UIControlEventTouchUpInside ];
lessonDateTextField_.rightViewMode = UITextFieldViewModeAlways;
lessonDateTextField_.rightView = lessonDateButton;
lessonDateTextField_.delegate = self;
[ self.view addSubview: lessonDateTextField_ ];
//*------------------------------------初始化时间选择器--------------------------------------*//
//日期,显示timepicker,界面整体上移
datePicker_ = [ [ UIDatePicker alloc ] init ];
datePicker_.frame = CGRectMake( 0 , 480 , 320 , 216 );
datePicker_.datePickerMode = UIDatePickerModeDate;
[ self.view addSubview: datePicker_ ];
//*----------------------------------------------------------------------------------------*//
}
//日期选择按钮
- (void)lessonDateButtonDidPush
{
//tableview都移开
[ classTypeTableView_ removeFromSuperview ];
[ lessonClassroomTableView_ removeFromSuperview ];
[ lessonSectionTableView_ removeFromSuperview ];
[ schoolDistrictTableView_ removeFromSuperview ];
//设置完成按钮
UIBarButtonItem* doneButton =
[ [ [ UIBarButtonItem alloc ]
initWithBarButtonSystemItem: UIBarButtonSystemItemDone
target:self
action: @selector(doneDidPush) ] autorelease ];
[ self setToolbarItems: [ NSArray arrayWithObject: doneButton ] animated: YES ];
[ UIView beginAnimations: nil context: nil ];
[ UIView setAnimationDuration: 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;
[ UIView commitAnimations ];
}
//日期选择完成按钮
- (void)doneDidPush
{
NSDate* date = [ datePicker_ date ];
NSDateFormatter* dateFormatter = [ [ NSDateFormatter alloc ] init ];
[ dateFormatter setDateFormat: @"yyyy-MM-dd" ];
lessonDateTextField_.text = [ dateFormatter stringFromDate: date ];
[ UIView beginAnimations: nil context: nil ];
[ UIView setAnimationDuration: 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 ];
[ self setToolbarItems: [ NSArray arrayWithObject: spaceButton ] animated: YES ];
//隐藏日期选择器
datePicker_.frame = toolbarFrame;
[ UIView commitAnimations ];
}
- 日期选择代码,使用datepicker
- 日期滚动选择(使用DatePicker实现)
- 日期选择控件 (DatePicker)
- 日期选择datepicker
- 日期选择控件-DatePicker
- DatePicker - 日期选择插件
- DatePicker - 日期选择插件
- Android-使用TimerPicker和DatePicker选择时间和日期
- UWP 使用日期选择控件DatePicker时的注意事项
- 联合使用DatePicker和TimePicker来选择日期和时间
- 联合使用DatePIcker和TimePicker来选择日期和时间
- JAVA Swing日期选择控件datepicker的使用
- Datepicker日期选择框插件
- 日期选择插件 My97 Datepicker
- android 日期选择控件 DatePicker
- 时间选择器,选择日期DatePicker
- jQuery学习之:Datepicker日期选择插件
- JQuery学习笔记:Datepicker日期选择控件
- 函数返回值
- decision tree
- sql server2008如何创建外键
- MongoDB单机, 主从, 分布式部署
- C#中引用类型和值类型分别有哪些
- 日期选择代码,使用datepicker
- SSH配置安全的文件共享
- 堆 和 栈的 区别(经典)
- 关于人生路的思考
- Unity3D动态加载FBX文件
- 用tigervnc实现多用户远程访问服务器
- 用C写一个程序,打印出所有的源程序,要求不能用文件。
- SQL Server 高性能写入的一些总结
- ubuntu 下编译安装opencv 2.3.1