I was looking for any advice for my problem. But I can not find a solution for this.
I created a subclass of UITableviewCell (FeedCell). With one image and two labels. The problem is that the shortcut, which should be multi-line, does not appear with multi-lines.
I use autolayot.
This is an application that displays twitterfeed users.
My code is:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; FeedCell *tweetCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (tweetCell == nil) { tweetCell = [[FeedCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; [tweetCell.tweetText setNumberOfLines:0]; [tweetCell.tweetText setLineBreakMode:NSLineBreakByWordWrapping]; [tweetCell.tweetText setFont:[self fontForCell] ]; } NSDictionary *tweet = _dataSource[[indexPath row]]; NSString *tweetString = [tweet valueForKey:@"text"]; tweetCell.name.text =[tweet valueForKeyPath:@"user.name"]; [tweetCell.tweetText setText:tweetString]; return tweetCell;
}
I also installed heigthforRowAtIndexPath:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *tweet = _dataSource[[indexPath row]]; NSString *theText=[tweet valueForKey:@"text"]; UIFont *cellFont = [self fontForCell]; CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT); CGSize labelSize = [theText sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByWordWrapping]; return labelSize.height + 20;
}
The problem is that the tweet cell.tweetText does not display with multi-lines. I have not tried this with another CellStyle (I use a custom cell style).
Someone tell me?
source share