カスタムtableViewCell
クラスのセルを複数行にして折り返すようにしました。ここでQ&Aを読み、指示に従いますが、それでも解決策を見つけることができません。
コンテンツの長さごとに動的な高さを調整できますが、それでも作成できません。これが私のコードです
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomItemCell"];
if(cell == nil){
cell = [[CustomItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CustomItemCell"];
//I set lineBreakMode of cell.postLabel to NSLineBreakByWordWrapping
// and set numberofLines = 0 ;
cell.postLabel.lineBreakMode = NSLineBreakByWordWrapping;
cell.postLabel.numberOfLines = 0;
}
CustomItem *item = [[channel items] objectAtIndex:[indexPath row]];
//postLabel is the label that I want to be multiline and wordwrap
// postLabel get an NSString from [item post]
[[cell postLabel] setText:[item post]];
[[cell timeLabel] setText:[item time]];
[[cell distanceLabel] setText:[item distance]];
[[cell thumbnailView] setImage:[item thumbnail]];
return cell;
}
CustomItemCell.xib
ファイルを作成しました。実際、Interface Builderで行をゼロに設定し、改行をワードラップに設定しましたが、期待どおりに表示されません。