miércoles, 28 de agosto de 2013

Poner una imagen en un control UIPickerView

Hay que utilizar este metodo en lugar del que solo devuelve el texto.

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
     NSString *t=@"";
     UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 32)];
    UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 250, 25)];
             t=def.funciones[row];
               UIImage *img = [UIImage imageNamed:@"Nombredelaimagen"];
             UIImageView *temp = [[UIImageView alloc] initWithImage:img];
             temp.frame = CGRectMake(0, 0, 25, 25);
                [tmpView insertSubview:temp atIndex:0];
     channelLabel.text = @"El texto que quieres";
    [channelLabel adjustsFontSizeToFitWidth];
    channelLabel.textAlignment = UITextAlignmentLeft;
    channelLabel.backgroundColor = [UIColor clearColor];
    [tmpView insertSubview:channelLabel atIndex:0];
   
    return tmpView;


}

No hay comentarios:

Publicar un comentario