0
약간의 문제가 있습니다. UITableViewCell (중앙)에서 여러 (동적 양) UIImages 표시 싶어요.행에 IOS 중심의 UIImages가 있습니다.
어떻게하면됩니까? (UIImages는 프로그래밍 방식으로 생성됩니다)?
고맙습니다.
약간의 문제가 있습니다. UITableViewCell (중앙)에서 여러 (동적 양) UIImages 표시 싶어요.행에 IOS 중심의 UIImages가 있습니다.
어떻게하면됩니까? (UIImages는 프로그래밍 방식으로 생성됩니다)?
고맙습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
self.imgThings = [[UIImageView alloc] init];
// imgThings.backgroundColor= [UIColor magentaColor];
[self.imgThings setImage: [UIImage imageNamed:@"image.png"]];
self.imgThings.center = CGPointMake(cell.contentView.bounds.size.width/2,cell.contentView.bounds.size.height/2);
[cell.contentView addSubview:self.imgThings];
}
return cell;
}
위 그림은 하나의 이미지에 대한 간단한 예입니다. 이미지의 이름을 변경하여 여러 이미지에 설정할 수도 있습니다.
안녕하세요, 귀하의 스 니펫에 감사드립니다. 거의 필요한 것. 그러나 나의 예에서는 하나의 행에 하나의 이미지 만있는 것이 아니라 여러 이미지를 가지고있다. 예를 들어 이것은 행입니다 : (UIImage) | (UIImage) | (UIImage) - (DetailEnclosure); 하나의 행과 여러 개의 열이있는 테이블과 같습니다. – Bene
@ Beene 이미지가 4 개 이상이면 어떨까요? – Anupdas
@Bene iOS 6.0 이상을 타겟팅하는 경우 자동 학습을 배우기에 좋은시기입니다. 규칙을 설정하여 패딩 및 규칙을 최소로 유지하여 모든 imageView의 높이 및 너비가 셀의 contentView와 같도록 할 수 있습니다. – Anupdas