FXForms
FXForms copied to clipboard
Fix text view sizing when using custom fonts
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.
+1
Would be nice to review that PR. We are still using our fork because the official one isn't supporting that.
+1, please review and merge this.