Iphone/Objective-c将图像和文本加载到双选择器中

Iphone/Objective-c将图像和文本加载到双选择器中,iphone,objective-c,uiimage,picker,Iphone,Objective C,Uiimage,Picker,我一直在尝试使用双重选择器来显示文本和图像。左选择器将有文本,右选择器将有图像。当我做文本时,它工作得很好,但当我试图使图像出现时,我得到一个错误,即 0x6b8b230>setValue:forUndefinedKey::此类不符合键列1的键值编码。' 到目前为止我已经做到了,但是我被卡住了,不知道该怎么办 @property (strong, nonatomic) NSArray *textvals; @property (strong, nonatomic) NSArray *imagev

我一直在尝试使用双重选择器来显示文本和图像。左选择器将有文本,右选择器将有图像。当我做文本时,它工作得很好,但当我试图使图像出现时,我得到一个错误,即 0x6b8b230>setValue:forUndefinedKey::此类不符合键列1的键值编码。' 到目前为止我已经做到了,但是我被卡住了,不知道该怎么办

@property (strong, nonatomic) NSArray *textvals;
@property (strong, nonatomic) NSArray *imagevals;
@synthesize textvals;
@synthesize imagevals;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSArray *totalArray = [[NSArray alloc] initWithObjects:@"Text 1",
                             @"text2", @"text 3", @"text 4", nil];
    self.textvals = totaltextArray;
    UIImage *image1 = [UIImage imageNamed:@"first.png"];
    UIImage *image2 = [UIImage imageNamed:@"second.png"];
    UIImage *image3 = [UIImage imageNamed:@"third.png"];
    UIImage *image4 = [UIImage imageNamed:@"fourth.png"];
    UIImageView *image1View = [[UIImageView alloc] initWithImage:image1];
    UIImageView *image2View = [[UIImageView alloc] initWithImage:image2];
    UIImageView *image3View = [[UIImageView alloc] initWithImage:image3];
    UIImageView *image4View = [[UIImageView alloc] initWithImage:image4];
    NSArray *totalimagearray = [[NSArray alloc] initWithObjects:image1View, image2View, image3View, image4View,nil];
    //[self setValue:totalimagearray forKey:"1"];
    self.imagevals = totalimagearray;
}

是的,这是绝对可能的。您需要处理pickerView委托方法

  • (UIView*)pickerView:(UIPickerView*)pickerView视图FORROW:(NSInteger)行 forComponent:(NSInteger)组件重用视图:(UIView*)视图
在这里,您只需返回自定义视图(可以是任何UIImage UILabel)


并将自定义视图的userInteractionEnable属性设置为“否”。

谢谢,在我的例子中,自定义视图指的是什么,我还是有点困惑。如何在(UIView*)pickerView:(UIPickerView*)pickerView中启用userInteractionEnable。。。?再次感谢您创建一个简单的视图并将该图像添加到该视图中