셀의 contentView 속성을 사용하여 UILabels
이 내 테이블보기 셀에 표시되지 않는 문제가 있습니다. UILabels
은 UIImage를 셀에 추가하기 전에 표시되었습니다. 셀에 텍스트를 추가하고 cell.contenView를 사용하여 원하는 위치에 UILAbels을 배치 할 수있었습니다.contentView 속성을 사용하여 테이블보기 셀에 UILabels이 표시되지 않습니다.
감사합니다. 내가있는 contentView를 사용하는 대신 cell.textLabel.text = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"title"];
을 추가하면 셀 텍스트가있는 권리를 표시 또한
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellReuseIdentifier = @"cellReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellReuseIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifier];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 2, 320, 30)];
titleLabel.tag = 234234;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = [UIColor whiteColor];
[titleLabel setFont:[UIFont fontWithName:@"DIN" size:24]];
titleLabel.layer.shadowColor = [[UIColor whiteColor] CGColor];
titleLabel.layer.shadowOpacity = 0.7;
titleLabel.layer.shouldRasterize=YES;
[cell.contentView addSubview:titleLabel];
UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 160, cell.bounds.size.width, 30)];
detailLabel.tag = 345345;
detailLabel.backgroundColor = [UIColor clearColor];
detailLabel.textColor = [UIColor whiteColor];
[detailLabel setFont:[UIFont fontWithName:@"DIN" size:18]];
detailLabel.layer.shadowColor = [[UIColor whiteColor] CGColor];
detailLabel.layer.shadowOpacity = 0.7;
detailLabel.layer.shouldRasterize=YES;
[cell.contentView addSubview:detailLabel];
}
UILabel *titleLabel = (UILabel *)[cell viewWithTag:234234];
titleLabel.text = (NSString *)[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"title"];
UILabel *detailLabel = (UILabel *)[cell viewWithTag:345345];
detailLabel.text = (NSString *)[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"description"];
NSString *imageUrlString = [NSString stringWithFormat:@"%@", [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
UIImage *cachedImage = [self.imageCache objectForKey:imageUrlString];
if (cachedImage)
{
cell.imageView.image = cachedImage;
}
else
{
cell.imageView.image = [UIImage imageNamed:@"rest.jpg"]; // initialize the image with blank image as a placeholder
// download in the image in the background
[self.imageDownloadingQueue addOperationWithBlock:^{
NSURL *imageUrl = [NSURL URLWithString:imageUrlString];
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = nil;
if (imageData)
image = [UIImage imageWithData:imageData];
if (image)
{
[self.imageCache setObject:image forKey:imageUrlString]; // add the image to your cache
// finally, update the user interface in the main queue
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
// make sure the cell is still visible
UITableViewCell *updateCell = [tableView cellForRowAtIndexPath:indexPath];
if (updateCell)
cell.imageView.image = image;
}];
}
}];
}
return cell;
}
:
여기 내 코드입니다.
detailLabel.textColor = [UIColor whiteColor];
당신은 흰색 배경에 흰색 글꼴 색상을 보여주기 위해 노력하고 :
셀의 기본 이미지 뷰가 레이블을 중첩되어있을 수 있습니다. 이미지를 해당 이미지 뷰로 설정하지 말고 이미지 뷰의 배경색을 지우고 레이블이 제대로 표시되는지 확인하십시오. –
@iUser 나는 그것을 시도했지만 아무런 표시가 나타나지 않습니다. cell.textLabel.text = [[publicDataArray objectAtIndex : indexPath.row]를 추가하면 objectForKey : @ "title"]; 콘텐츠를 사용하는 대신 셀 텍스트는 오른쪽에서 표시됩니다. 스크린 샷을 추가했습니다 – hanumanDev