Вечер,
У меня есть несколько UITableViewCell, которые динамически расширяются по высоте на основе текста, содержащегося в них, но кажется, что после ввода определенного количества символов (хотя я еще не проверял это, поэтому я не уверен, что это именно то, причина), высота вычисляется неправильно.
Вот соответствующие части моего кода с примером строки, которая вызывает проблему, преднамеренно урезанная до 1000 символов (максимальная длина поля, в которое может вводить пользователь):
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.
Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's NeXTSTEP operating system. Generic Objective-C programs that do not use these libraries can also be compiled for any system supported by gcc or Clang.
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.
Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's NeXTSTEP operating system. Generic Objective-C programs that do no
Это из моего cellForRowAtIndexPath:
..
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;
Затем я вычисляю высоту ячейки, используя следующее:
- (CGFloat)tableView:(UITableView *)t heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellLabel;
NSString *cellText;
if (indexPath.section == 0) {
// This returns a small string such as 'Note'
cellLabel = [generalDetailsCellsArray objectAtIndex:indexPath.row];
// This returns the example string posted in the above block
cellText = [generalDetailsValuesArray objectAtIndex:indexPath.row];
}
--- snip ---
CGSize constraint = CGSizeMake(300.0f, 20000.0f);
CGSize labelSize = [cellLabel sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:constraint];
CGSize textSize = [cellText sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:constraint];
return (labelSize.height + textSize.height) + 12;
}
Кто-нибудь может увидеть какие-либо явно очевидные сообщения?
Заранее спасибо.