UIPickView 基本使用
2016-08-04 17:48
375 查看
// 选择框
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];
}}
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];
}}
相关文章推荐
- iOS UIPickView和UIDatePicker的基本使用
- UIPickView的基本使用
- UIPickView的使用
- ios-UIPickerView基本使用
- IOS的基本控件的使用-UISlider&UIProgressView
- UI 一一 UIScrollView的基本使用详解
- iOS-UICollectionView基本使用
- 学习IOS开发UI篇--UICollectionViewController的基本使用
- UI 基础----UIScrollView 的基本属性使用以及代理的使用方法
- iOS控件-UICollectionView基本使用详解(OC)
- UIPickView的使用和
- UISplitViewController基本使用方法
- iOS开发之有趣的UI—— UITableView控件基本使用
- UiPickerView基本使用方法
- iOS控件-UICollectionView基本使用详解(OC)
- UIPickView的使用
- UI基础之UITableView的基本使用
- UIScrollView的基本使用方法和注意事项 - iOS - UI基础知识总结10
- ioS开发之UI基础--UIScrollView的基本使用
- iOS控件-UICollectionView基本使用详解