我已实现以下功能:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
UIImage *img = [UIImage imageNamed:@"persona.jpeg"];
UIImageView *temp = [[UIImageView alloc] initWithImage:img];
temp.frame = CGRectMake(-70, 10, 60, 40);
UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, -5, 80, 60)];
channelLabel.text = @"persona y";
channelLabel.textAlignment = UITextAlignmentLeft;
channelLabel.backgroundColor = [UIColor clearColor];
UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 110, 60)];
[tmpView insertSubview:temp atIndex:0];
[tmpView insertSubview:channelLabel atIndex:1];
return tmpView;
}
,结果如下:
我需要在特定的行中插入图片和文字,知道怎么做吗? 非常感谢你的帮助。
我的想法是填充一系列图片和描述以填充UIPickerView
答案 0 :(得分:7)
尝试将您的数据设为Array
的{{1}}。
字典结构:NSDictionary
{Image:<imageName>, LabelText:<labelText>}