Reputation: 1865
I tried to make the cell in my custom tableViewCell
class to be multi-line and wrap.
I read my Q&A here and follow the instructions but still unable to find a solution.
I can adjust the dynamic height per content length but still unable to make the Here is my code
-(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;
}
I created the CustomItemCell.xib
file. And actually, I also set the line to zero and the linebreak to wordwrap in interface builder but it is not shown as I expected.
Upvotes: 2
Views: 1375
Reputation: 6541
set cell style as shown below for multi-line,
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
check it..
Upvotes: 1