UiPickerView 与图像错误



我有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

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

最新更新