2010-11-26 5 views
7

두 개의 열이있는 UIPickerView가 있으며 한 열에는 이미지와 레이블이 표시됩니다. 그것은 작동합니다. 디스플레이 및 이미지 및 레이블, 그냥 레이블이 이미지 아래 왼쪽에 이미지를 넣고 오른쪽에 레이블이 있습니까? 오른쪽으로 레이블 정렬을 시도했지만 작동하지 않습니다.구성 요소에 레이블이있는 UIPickerview 이미지

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

답변

7

channelLabel에 적절한 프레임을 설정하십시오. 올바른 프레임 원점 X 값 (CGRectMake 함수의 첫번째 매개 변수) 좌표 설정 이미지 뷰의 왼쪽 예에 배치하려면 :

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

고마워요 :) 그리고 하나 더 질문은 uipickerview 구성 요소 목록을 만들 수있는 방법이있다 그 안에 항목을 반복하는 것. 예를 들어 첫 번째 항목을 다시 표시하려면 10 번째 항목 이후에 항목이 10 개있는 경우입니다. 품질 자습서가 있습니까? – 1110

+0

예를 들어이 질문보기 : http://stackoverflow.com/questions/214441/how-do-you-make-an-uipickerview-component-wrap-around – Vladimir

관련 문제