Airon Zagarella
Airon Zagarella

Reputation: 717

Iphone/Objective-c Loading images and texts into a double picker

I have been trying to get a double picker to show both text and images. the left picker will have text and the right will have images. When I do text, it works fine but when I try to make images appear I get an error that says 0x6b8b230> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key column1.' I got this so far but Im stuck and have no idea what to do.

@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;
}

Upvotes: 0

Views: 248

Answers (1)

Muzamil Hassan
Muzamil Hassan

Reputation: 851

yes it is absolutely possible. u need to handle pickerView delegate method

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

here you simply return custom view(could be anything UIImage UILabel)

and set userInteractionEnable property to no for customize view..

Upvotes: 1

Related Questions