19 iphone cocoa-touch objective-c ios
现在,选择器只显示正在选择的数据.我希望它在所选值之后有一个单词,就像iPhone时钟应用程序在选择器上有"小时"和"分钟"一样.

您必须使用以下方法自己创建两个标签。这是 pickerView 的委托方法,当 pickerview 加载或获取 reloadcomponent 命令时会自动调用。
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)theView{
UIView *pickerviewtemp=[[UIView alloc] initWithFrame:CGRectZero];
UILabel *lbl=[[[UILabel alloc] initWithFrame:yourrequiredframe]autorelease];
[lbl setBackgroundColor:[UIColor clearColor]];
[lbl setText:*set text according to yourself*];
[lbl setFont:[UIFont boldSystemFontOfSize:16]];
[pickerviewtemp addSubview:lbl];
UILabel *lb2=[[[UILabel alloc] initWithFrame:yourrequiredframe]autorelease];
[lbl2 setBackgroundColor:[UIColor clearColor]];
[lbl2 setText:*set text according to yourself*];
[lbl2 setFont:[UIFont boldSystemFontOfSize:16]];
[pickerviewtemp addSubview:lbl2];
return pickerviewtemp;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7616 次 |
| 最近记录: |