나는 현재 내 jQuery과 내 cellForRowAtIndexPath에 대한 다음과 같은 코드가 있습니다있는 UITableViewCell 내용보기 - 추가 UILabels
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* CellIdentifier = @"Cell";
UILabel* nameLabel = nil;
UILabel* valueLabel = nil;
UILabel *percentLabel = nil;
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil)
{
inthere = YES;
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault
reuseIdentifier: CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
nameLabel = [[[UILabel alloc] initWithFrame:CGRectMake(7.0, 0.0, 140.0, 44.0)] autorelease];
nameLabel.tag = 21;
nameLabel.font = [UIFont systemFontOfSize: 12.0];
nameLabel.textAlignment = UITextAlignmentLeft;
nameLabel.textColor = [UIColor darkGrayColor];
nameLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
nameLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview: nameLabel];
valueLabel = [[[UILabel alloc] initWithFrame: CGRectMake(165.0, 0.0, 80, 44.0)] autorelease];
valueLabel.tag = 22;
valueLabel.font = [UIFont systemFontOfSize: 11];
valueLabel.textAlignment = UITextAlignmentRight;
valueLabel.textColor = [UIColor blueColor];
valueLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
valueLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview: valueLabel];
percentLabel = [[[UILabel alloc] initWithFrame: CGRectMake(245, 0.0, 65, 44.0)] autorelease];
percentLabel.tag = 24;
percentLabel.font = [UIFont systemFontOfSize: 12];
percentLabel.textAlignment = UITextAlignmentRight;
percentLabel.textColor = [UIColor blueColor];
percentLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
percentLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview: percentLabel];
}
else
{
nameLabel = (UILabel*)[cell.contentView viewWithTag:21];
valueLabel = (UILabel*)[cell.contentView viewWithTag:22];
percentLabel = (UILabel *)[cell.contentView viewWithTag:24];
}
...and then I initialize the text of each of these three labels...
}
하지만를 내가 뭘하고 싶은 세 가지 라벨 따라 색상이 다를 수 있습니다입니다 세포에. 예를 들어 섹션 3의 모든 셀에는 빨간색 이름 라벨이 있어야하고 섹션 5의 모든 셀에는 녹색 valueLabels이 있어야합니다. 나는 모든 레이블의 텍스트를 초기화 한 후 내가 코드에이를 삽입한다면 :
if(indexPath.section==3) {
nameLabel.textColor = [UIColor redColor];
}
if(indexPath.section==5) {
valueLabel.textColor = [UIColor greenColor];
}
는 모든 것이 엉망이됩니다 테이블 텍스트의 색상이 잘못되는 이상한 장소 및 라벨에있는과 함께, 모든 glitchy이며, 다소 임의적으로 보입니다.
테이블의 모든 단일 셀에 대해 세 라벨의 색상을 어떻게 지정합니까?
는이 glitchyness의 스크린 샷을 공급할 수를 재설정 한? –
아닙니다. 일종의 개인 정보입니다. 그러나 콘텐츠 조회수가 주변에서 섞여 있고 적절하게 정리되지 않았거나 그와 비슷한 것이 분명합니다. – CodeGuy
텍스트가 이상한 장소에 있는지, 아니면 색상이 잘못 되었습니까? – Anna