2010-11-26 22 views
7

İki sütunlu UIPickerView'ım var ve bir sütunda, yanında resim ve etiket görüntülemek istiyorum. İşe yarıyor. Ekran ve görüntü ve etiket, sadece etiket resmin altında solda resim koymak ve sağ tarafta etiket nasıl? Etiket hizalamayı değiştirmeye çalıştım ama işe yaramıyor.Bileşen etiketli UIPickerview resmi

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row 
       forComponent:(NSInteger)component reusingView:(UIView *)view 
    { 
     if(component == kStateComponent) 
     { 
     UIImage *img = [UIImage imageNamed:@"rts1.png"]; 
     UIImageView *temp = [[UIImageView alloc] initWithImage:img];   
     temp.frame = CGRectMake(0, 0, 29, 29); 


      UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 60)]; 
      channelLabel.text = @"sdfsdfdsf"; 
      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; 
     } 
    ... 
    } 

cevap

7

Kanalınız için uygun çerçeveyi ayarlayınLabel. Doğru çerçeve kökenli x değeri (CGRectMake işlevinde 1 parametresini) koordinat set imageview solunda, örneğin için konumlandırmak için:

UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 60, 60)]; 
+0

Çok teşekkürler :) Ve bir soru daha UIPickerView bileşeni listesini yapmak için herhangi bir yol yoktur içindeki öğeleri tekrarlamak için Örneğin, ilk öğeyi tekrar görüntülemek için 10'dan sonra 10 öğe varsa. Herhangi bir kaliteli eğitim var mı? – 1110

+0

bu soruyu şu örnekte görebilirsiniz: http://stackoverflow.com/questions/214441/how-do-you-make-an-uipickerview-component-wrap-around – Vladimir