Попробуйте этот подход.
1. Использование UITextView
Это даст вам возможность прокручивать текст внутри UITextView
, если текст будет очень большой.
2. Получить размер вас текста зрения // возвращает размер для UITextView как для IOS7 и iOS6
-(CGSize) getSizeWithMaxLabelSize:(CGSize) maxLabelSize forTextViewWithText:(NSString *) text
{
CGSize expectedLabelSize;
CGSize maximumLabelSize = maxLabelSize;
if (SYSTEM_VERSION_GREATER_THAN(@"6.2")) {
NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:[UIFont fontWithName:@"Arial" size:12] forKey: NSFontAttributeName];
CGRect rect =[text boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:stringAttributes context:nil];
expectedLabelSize = rect.size;
expectedLabelSize.height = ceilf(expectedLabelSize.height);
expectedLabelSize.width = ceilf(expectedLabelSize.width);
} else {
expectedLabelSize = [text sizeWithFont:[UIFont fontWithName:@"Arial" size:EPCommentViewFontSize] constrainedToSize:maximumLabelSize lineBreakMode:NSLineBreakByWordWrapping];
}
return expectedLabelSize;
}
3. Используйте этот метод (2) при вычислении высоты ячейки для вас таблица - tableView:cellForRowAtIndexPath:
Выглядит как прекрасный пример для UITableView. Вы можете использовать методы NSString для вычисления размера, который будет иметь ваша строка. Этот размер можно вернуть из метода '- tableView: cellForRowAtIndexPath:' delegate. –