FXForms icon indicating copy to clipboard operation
FXForms copied to clipboard

Fix text view sizing when using custom fonts

Open SebastianThiebaud opened this issue 10 years ago • 3 comments

Problem:

Right now, when we use a custom font for the -[FXFormTextViewCell textView] the height isn't right. + (CGFloat)heightForField:(FXFormField *)field width:(CGFloat)width is initializing a static UITextView object with [UIFont systemFontOfSize:17]; value for the font property.

Solution:

An easy way to solve that issue is adding a class method that could be override by a subclass. + (UITextView *)textViewForSizing is returning a custom UITextView that can be used by the sizing method. But + (CGFloat)heightForField:(FXFormField *)field width:(CGFloat)width needs to resign its dispatch_once block. The static UITextView object would make useless a subclass override of + (UITextView *)textViewForSizing. This last method is now responsible of the dispatch_once block. For this reason, it would might be clever to update the documentation and ask any developers integrating that feature to be sure to take care of that GCD block for performance reasons.

SebastianThiebaud avatar Feb 10 '15 00:02 SebastianThiebaud

+1

markst avatar Apr 15 '15 00:04 markst

Would be nice to review that PR. We are still using our fork because the official one isn't supporting that.

SebastianThiebaud avatar Apr 15 '15 00:04 SebastianThiebaud

+1, please review and merge this.

abbasmousavi avatar Jun 14 '15 13:06 abbasmousavi