ios-王云鹤 把UIdatePicker 嵌入到 UIActionSheet中
来源:互联网 发布:淘宝网开设网店的规律 编辑:程序博客网 时间:2024/06/07 11:01
- 这里简单的解释一下:
-(void) setUpDatePicker方法用于调用UIDatePicker
-(void) DatePickerDoneClick:(id) sender方法用于实现隐藏UIdatePicker
-(void) dateChanged:(id)sender方法实现获取日期结果值的方法。
如果没有实现效果,别忘记加上协议,这个是比较容易忘记的
- -(void) setUpDatePicker
- {
- //点击显示时间
- self.actionSheet= [[UIActionSheet alloc] initWithTitle:nil
- delegate:self
- cancelButtonTitle:nil
- destructiveButtonTitle:nil
- otherButtonTitles:nil];
- UISegmentedControl*cancelButton =[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"取消"]];
- UISegmentedControl*confirmButton =[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"确定"]];
- [self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
- // Add the picker
- self.datePicker= [[UIDatePicker alloc] init];
- self.datePicker.datePickerMode= UIDatePickerModeDate;
- [self.datePicker addTarget:self
- action:@selector(dateChanged:)
- forControlEvents:UIControlEventValueChanged];
- [self.actionSheet addSubview:self.datePicker];
- [self.actionSheet showInView:self.view];
- [self.actionSheet setBounds:CGRectMake(0,0,320,500)];
- CGRect pickerRect;
- pickerRect = self.datePicker.bounds;
- pickerRect.origin.y= -50;
- self.datePicker.bounds= pickerRect;
- cancelButton.momentary= YES;
- cancelButton.frame= CGRectMake(10.0f,7.0f, 65.0f, 32.0f);
- cancelButton.segmentedControlStyle= UISegmentedControlStyleBar;
- [cancelButton addTarget:self action:@selector(DatePickerDoneClick:) forControlEvents:UIControlEventValueChanged];
- [self.actionSheet addSubview:cancelButton];
- cancelButton.tag= 1;
- confirmButton.momentary= YES;
- confirmButton.frame= CGRectMake(245.0f,7.0f, 65.0f, 32.0f);
- confirmButton.segmentedControlStyle= UISegmentedControlStyleBar;
- [confirmButton addTarget:self action:@selector(DatePickerDoneClick:) forControlEvents:UIControlEventValueChanged];
- [self.actionSheet addSubview:confirmButton];
- confirmButton.tag= 2;
- [self.actionSheet showInView:self.view];
- [self.actionSheet setBounds:CGRectMake(0,0,320, 500)];
- }
- -(void)DatePickerDoneClick:(id) sender
- {
- UIButton*button =(UIButton*)sender;
- if(button.tag== 1)
- {
- [self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];
- }
- if(button.tag== 2)
- {
- [self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];
- }
- }
- -(void) dateChanged:(id)sender
- {
- NSDate*dateValue =[NSDate date];
- NSDateFormatter*dateFormatter =[[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- dateValue =((UIDatePicker*)sender).date;
- self.teleplayDate.text= [dateFormatter stringFromDate:dateValue];//[NSString stringWithFormat:@"%@",dateValue];
- }
- ios-王云鹤 把UIdatePicker 嵌入到 UIActionSheet中
- UIDatePicker 添加到 UIActionSheet 上
- 把窗体嵌入到容器中
- 使用UIActionSheet 弹出UIDatePicker
- UIActionSheet 弹出UIDatePicker
- UIActionSheet和UIDatePicker以及UIPickerView
- MMPopupView(自定义UIAlertView、UIActionSheet、UIDatePicker)
- c# 把窗体嵌入到容器控件中
- 把Google地图嵌入到自己的网页中
- 把你的Access数据库嵌入到资源中发布
- 把exe嵌入到自己的exe中。delphi xe3
- delphi把窗体嵌入到dll中。实现方法
- JavaScript计算值然后把值嵌入到html中。
- 如何把React Native嵌入到原生android应用中
- iOS中UIActionSheet的使用
- ios中UIActionSheet的误区
- iOS中UIActionSheet的使用
- IOS中UIActionSheet使用详解
- [summary]-SIGMETRICS'13: Tolerating Path Heterogeneity in Multipath TCP with Bounded Receive Buffers
- 消息推送原理及评价标准
- 迭代器模式(Iterator Pattern)
- CSS3实战手册(第3版)(影印版)
- Linux系统安全配置的一些规则(整理)
- ios-王云鹤 把UIdatePicker 嵌入到 UIActionSheet中
- 批量添加用户(newusers,chpasswd)
- 黑马程序员_毕向东_Java基础_DAY02学习笔记
- Java执行Runtime.getRuntime().exec()
- linux下获取程序当前目录绝对路径
- ssh互信
- Linux内核驱动模块编写概览-ioctl,class_create,device_create
- 解决ubuntu下 error occurred during the signature verification
- Opencv Python版学习笔记(二)漫水填充