저는 storyboard에서 작업 중입니다. View Controller를 tableViewVC에서 상속 받았습니다. 그 vc에서 나는 한 줄 또는 두 줄의 텍스트가있는 셀을 가지고 있습니다. 한 줄이 있으면 커스텀 셀의 텍스트 텍스트를 텍스트에 할당합니다. 2 줄이 있으면 라벨 프레임의 크기를 조정합니다. 그러나 테이블이로드 될 때 작동하지 않습니다. tableView 위/아래로 스크롤 한 후에 만 셀의 크기가 조정 된 레이블을 볼 수 있습니다. 어떻게 해결할 수 있습니까?레이블의 프레임 크기가 tableView 셀에서 변경되지 않습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
OptionItem *item = _currentOptionsList[indexPath.row];
static NSString *CellIdentifier = @"OptionSimpleCellIdentifier";
OptionSimpleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.titleLabel.text = item.title;
cell.haveDetail = item.haveDetailItems;
cell.selectedSimpleOption = item.simpleSelected;
if (item.haveSelectedDetailItem)
{
cell.detailLabel.text = [item.detailItems[item.indexOfSelecteDetaildItem] title];
} else {
cell.detailLabel.text = nil;
cell.detailImageView.image = nil;
}
CGFloat textHeight = [Calculatons getLabelHeightForText:item.title andWidth:225 withFont:kFontListCell withMaxHeight:0];//19 - 39
CGRect rect = cell.titleLabel.frame;
NSLog(@"textHeight = %f cell.height = %f titleLabel.height %f \n",textHeight, cell.frame.size.height, cell.titleLabel.frame.size.height);
if (textHeight > 21)
{
rect.size.height = 41;
cell.titleLabel.frame = rect;
}
//nothing of this not works
[cell.titleLabel layoutIfNeeded];
[cell.titleLabel setNeedsLayout];
[cell.titleLabel setNeedsUpdateConstraints];
[cell.titleLabel setNumberOfLines:0];
return cell;
}
http://s23.postimg.org/8tszefzbf/Screen_Shot_2014_08_27_at_10_01_10_PM.png
첫 화면 후 난 VS. 밀어 두 번째 화면은 테이블을 위아래로 스크롤 한 후 나타나는 화면입니다.
VC를 누른 후 결과로 두 번째 화면이 필요합니다.