UIPickerView 双排选择时间点
来源:互联网 发布:耳机一定要煲机吗 知乎 编辑:程序博客网 时间:2024/04/29 10:04
UIPickerView *boottime;
UIPickerView *shutdown;
int currenthour;
int currentminute;
NSArray *hour;
NSArray *minute;
NSString *boothour;
NSString *bootmintue;
NSString *str1;
NSString *str2;
hour = @[@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23"];
minute =@[@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"58",@"59"];
currenthour =0;
currentminute =0;
3.代理方法 UIPickerViewDataSource,UIPickerViewDelegate
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
NSInteger result;
if(component ==0){
result = hour.count;
}
if(component ==1){
result = minute.count;
}
return result;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
NSString *result;
if(component ==0){
result = [hourobjectAtIndex:row];
}
if(component ==1){
result = [minuteobjectAtIndex:row];
}
return result;
}
3.
-(void)selectTime{
if(boottime ==nil){
boottime = [[UIPickerViewalloc]init];
boottime.frame =CGRectMake(WIDTH/6,HEIGHT/12,WIDTH/3*2,HEIGHT/6);
boottime.dataSource =self;
boottime.delegate =self;
}
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"开机时间:"message:@"\n\n\n\n\n\n\n\n\n"preferredStyle:UIAlertControllerStyleActionSheet];
[alertController.viewaddSubview:boottime];
UIAlertAction *actionSelect = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction *action) {
currenthour = (int)[boottimeselectedRowInComponent:0];
currentminute = (int)[boottimeselectedRowInComponent:0];
boothour = [hourobjectAtIndex:currenthour];
bootmintue = [minuteobjectAtIndex:currentminute];
str1 = [NSStringstringWithFormat:@"%@:%@",boothour,bootmintue];
[_btnstartsetTitle:str1forState:UIControlStateNormal];
NSLog(@"%@",str1);
}];
[alertController addAction:actionSelect];
UIAlertAction *actionCancel = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
[alertController addAction:actionCancel];
[selfpresentViewController:alertControlleranimated:YEScompletion:nil];
}
-(void)selectShutdown{
if(shutdown ==nil){
shutdown = [[UIPickerViewalloc]init];
shutdown.frame =CGRectMake(WIDTH/6,HEIGHT/12,WIDTH/3*2,HEIGHT/6);
shutdown.dataSource =self;
shutdown.delegate =self;
}
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"关机时间:"message:@"\n\n\n\n\n\n\n\n\n"preferredStyle:UIAlertControllerStyleActionSheet];
[alertController.viewaddSubview:shutdown];
UIAlertAction *actionSelect = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction *action) {
currenthour = (int)[shutdownselectedRowInComponent:0];
currentminute = (int)[shutdownselectedRowInComponent:0];
boothour = [hourobjectAtIndex:currenthour];
bootmintue = [minuteobjectAtIndex:currentminute];
str2 = [NSStringstringWithFormat:@"%@:%@",boothour,bootmintue];
[_btnShutdownsetTitle:str2forState:UIControlStateNormal];
NSLog(@"%@",str2);
}];
[alertController addAction:actionSelect];
UIAlertAction *actionCancel = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
[alertController addAction:actionCancel];
[selfpresentViewController:alertControlleranimated:YEScompletion:nil];
}
- UIPickerView 双排选择时间点
- UIPickerView做好的时间选择
- UIPickerView(滚动选择控制器)
- iOS uipickerview 选择DATE
- UIPickerView + 城市选择
- UIPickerView城市选择
- [IOS]UIPickerView选择时间段
- UIPickerView - 城市选择
- UIPickerView选择省市
- UIPickerView(选择框)
- UIPickerView注意点
- 自定义时间选择器UIPickerView
- UIPickerView简单使用 - 点餐
- 股市买入卖出时间点选择问题
- 股市买入卖出时间点选择问题
- 股市买入卖出时间点选择问题
- UIPickerView 实现多列选择栏
- IOS UIPickerView控件的关联选择
- CSS值得关注的那些事?
- 关于UITableView的headerView和footerView
- mysql建索引
- XML Json数据
- 【30天学习C++ primer系列】day1:新的征程。-20160110
- UIPickerView 双排选择时间点
- mysql 个人笔记
- 从Linux下载文件到Windows putty pscp
- DBGrideh实现自动排序
- 实验5-8 使用函数统计指定数字的个数 (15分)
- STL_算法_查找算法(lower_bound、upper_bound、equal_range)
- iOS开发-----json解析的数据有图片的数据流导致解析失败
- Android中EditText 的setInputType以及setRawInputType区别
- Easyui使用中遇到的问题和注意事项