2011-12-10 2 views
0

UITableView의 단일 셀에 여러 이미지를 추가하려면 어떻게해야합니까?UITableView의 셀에 여러 이미지 추가

이미지를 사용하여 플레이어 상태를 표시하고 모든 플레이어가 동시에 여러 상태를 가질 수 있습니다.

답변

6

사용자 지정 셀을 만들기 위해 UITableViewCell을 상속합니다. 그 MyCustomCell라고합니다.

코드를 포맷하십시오 여러 이미지

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 

    //change frame sizes to palce the image in the cell 
     UIImageView * thumbnail1 = [[UIImageView alloc] initWithFrame:CGRectMake(17, 12, 62, 62)]; 
     thumbnail1.image = [UIImage imageNamed:@"Icon.png"]; 
     [self addSubview:thumbnail1]; 

     UIImageView * thumbnail2 = [[UIImageView alloc] initWithFrame:CGRectMake(17, 12, 62, 62)]; 
     thumbnail2.image = [UIImage imageNamed:@"Icon.png"]; 
     [self addSubview:thumbnail2]; 

     UIImageView * thumbnail3 = [[UIImageView alloc] initWithFrame:CGRectMake(17, 12, 62, 62)]; 
     thumbnail3.image = [UIImage imageNamed:@"Icon.png"]; 
     [self addSubview:thumbnail3]; 

    } 
    return self; 
} 
+0

에 대해 다음과 같이 다른 사람이 –

+0

내가 자습서를 발견 확인 [링크를 이해하는

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // In your case it has to be the custom cell object here. MyCustomCell *cell = (MyCustomCell*)[tableView dequeueReusableCellWithIdentifier:@"AnIdentifierString"]; if (cell == nil) { cell = [[[MyCustomCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"AnIdentifierString"] autorelease]; } //use your cell here // cell.textLabel.text = @"This text will appear in the cell"; return cell; } 

당신은, MyCustomCell의 스타일로 초기화를 대체 할 수 아래처럼 사용 ] (http://www.icodeblog.com/2008/09/02/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-2/) 감사합니다. –

+0

첫 번째 셀에 데이터가있는 경우 7 이미지가 있고 한 셀에 처음 세 개의 이미지를 표시하고 싶습니다. 세 번째 셀에 다른 세 개를 표시하고 세 번째 셀에 남아있는 이미지를 하나 하나 넣으려면 어떻게해야합니까? 거기에 어떤 해결책이 ...? – TheMall

관련 문제