0

我有 UiPickerView 和 colorCode.Plist - 其中包含图像的名称。

我需要将这些图像添加到我的选择器视图中。


拾取器视图

4个组件

前 3 个组件中的 10 个图像

第 4 个分量中的 4 个图像


电气用电阻器颜色代码等程序。(抛出错误)

  {
@interface ResistorsColorView ()
{
NSArray *colorCode;    
}

@end

@implementation ResistorsColorView


- (void)viewDidLoad

{
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"colorCode" ofType:@"plist"];
colorCode = [[NSArray alloc] initWithContentsOfFile:filePath];
}

#  pragma mark - Datasource

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
 return colorCode.count;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [colorCode[component]count];
}

//- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:    (NSInteger)component{
//
//    return colorCode[component][row];
//}



-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:            (NSInteger)component reusingView:(UIView *)view{


UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];

imageView.image = colorCode[component][row];

imageView.image = [UIImage imageNamed:[record objectForKey:@"row1"]];




[v addSubview:imageView];

return v;
}

@end
4

1 回答 1

0

原因:'-[__NSCFString _isResizable]:无法识别的选择器发送到实例 0x6e6e300' -

于 2013-10-26T22:52:32.457 回答