Hello, I set the size of my UITableCell´s with this:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString * vergleich = [nachricht objectAtIndex:indexPath.row];
CGSize size = [vergleich sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14]
constrainedToSize:CGSizeMake(268, MAX_HEIGHT)
lineBreakMode:UILineBreakModeWordWrap];
return size.height + 30;
}
nachricht is a NSArray which contains all the messages. The code just looks how long the message (with a specified font) is and calculate the height. I set + 30, because over the message(UITextView) is a UIlabel.
The UITextView, which should contain the messages, get the size with this code:
- (void)setTweetText:(NSString *)_tweet;{
CGSize size = [_tweet sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14]
constrainedToSize:CGSizeMake(268, MAX_HEIGHT)
lineBreakMode:UILineBreakModeWordWrap];
[textText setFrame:CGRectMake(55, 25, 268, size.height + 10)];
textText.text = _tweet;
[textText sizeToFit];
textText.dataDetectorTypes = UIDataDetectorTypeLink;
}
Now there is a problem and I don't know why: The UITextView is bigger then the cell, even if I set the size of the cell height there is a unpleasant distance between the TextView and the next cell. Why doesn't he get the right height for some cells. Here is an example: