Comment insert des images et du text dans des lignes spécifiques d'un UIpickerView?

J'ai mis en place la fonction suivante:

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

et le résultat est le suivant:

Écran

J'ai besoin d'insert l'image et le text dans une rangée spécifique, une idée de comment le faire?
Merci beaucoup pour votre aide.

Mon idée est de remplir un tableau de photos et une description pour remplir le UIPickerView

Essayez d'get vos données en tant que Array de NSDictionary .

Structure du dictionary: {Image:<imageName>, LabelText:<labelText>}

 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { NSDictionary *dict = [datasourceArray objectAtIndex:row]; UIImage *img = [UIImage imageNamed:[dict valueForKey:@"Image"]]; // get image path from the dictionary 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 = [dict valueForKey:@"LabelText"]; 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; }