Closed relatedcode closed 1 year ago
+1
// In QTextElement.m // - (CGFloat)getRowHeightForTableView:(QuickDialogTableView *)tableView {} // CGSize size= [_text sizeWithFont:self.appearance.valueFont constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping]; - deprecated in iOS7
One possible decision is to calculate TextElement height manually:
// Get width of device
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat offset = 800.0;
NSString *termsStr = [appDelegate languageSelectedStringForKey:@"Terms and conditions"]; // This is the text that will appear in QTextElement - it is very long in my case
NSAttributedString *termsAttrStr = [[NSAttributedString alloc] initWithString:termsStr attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:FONT_SIZE_14]}];
CGRect termsRect = [termsAttrStr boundingRectWithSize:CGSizeMake(screenWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil];
QTextElement *terms = [[QTextElement alloc] init];
terms.height = termsRect.size.height + offset;
terms.text = termsStr;
terms.appearance.valueFont = [UIFont systemFontOfSize:FONT_SIZE_14];
terms.color = grayTextColor;
Of course, the offset is random number that depends on text size. The decision is not very elegant but I think that the more important is that it works.
Another temporary way: CGSize constraint; if (SYSTEM_VERSION_LESS_THAN(@"7.0")) { constraint = CGSizeMake(tableView.frame.size.width-(tableView.root.grouped ? 40.f : 20.f), 20000); } else { constraint = CGSizeMake(tableView.frame.size.width-(tableView.root.grouped ? 60.f : 30.f), 20000); }
sizeWithFont in QTextElement is not work well on ios7 now.