UIPickerView
来源:互联网 发布:左程云 算法视频 下载 编辑:程序博客网 时间:2024/06/06 09:46
1
2
3
4
5
6
7
8
9
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
// 选择框
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 100, 320, 216)];
// 显示选中框
pickerView.showsSelectionIndicator=YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[self.view addSubview:pickerView];
[pickerView release];
_proTimeList = [[NSArray alloc]initWithObjects:@
"1"
,@
"2"
,@
"3"
,@
"4"
,@
"5"
,@
"6"
,@
"7"
,@
"8"
,@
"9"
,@
"10"
,nil];
_proTitleList = [[NSArray alloc]initWithObjects:@
"1"
,@
"2"
,@
"3"
,@
"4"
,@
"5"
,@
"6"
,@
"7"
,@
"8"
,@
"9"
,@
"10"
,nil
// pickerView 列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return
2;
}
// pickerView 每列个数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
if
(component == 0) {
return
[_proTitleList count];
}
return
[_proTimeList count];
}
// 每列宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
if
(component == 1) {
return
40;
}
return
180;
}
// 返回选中的行
- (
void
)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if
(component == 0) {
_proNameStr = [_proTitleList objectAtIndex:row];
}
else
{
_proTimeStr = [_proTimeList objectAtIndex:row];
}
}
//返回当前行的内容,此处是将数组中数值添加到滚动的那个显示栏上
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if
(component == 0) {
return
[_proTitleList objectAtIndex:row];
}
else
{
return
[_proTimeList objectAtIndex:row];
}
}
0 0
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIpickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIPickerView
- UIpickerview
- UIPickerView
- UIpickerView
- UIPickerView
- 面试1-HTTP状态码
- At91sam9g35K烧录Linux系统
- Qml文件的两种加载方式|启动Qt quick app的两种方法
- Yii createCommand CURD操作+个人总结
- 学习python2.7的迭代器
- UIPickerView
- 设计模式_观察者模式
- a:link,a:visited,a:hover,a:active 区别
- codeforces--651B Beautiful Paintings
- Linux平台weblogic集群安装(一)
- HTML学习笔记(一)
- 我的Android进阶之旅------>Android自定义View实现带数字的进度条(NumberProgressBar)
- hdu2255奔小康赚大钱 KM算法
- Java——FileInputStream&FileOutputStream字节流实现文件复制