Fix text view sizing when using custom fonts #305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 staticUITextView
object with[UIFont systemFontOfSize:17];
value for thefont
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 customUITextView
that can be used by the sizing method.But
+ (CGFloat)heightForField:(FXFormField *)field width:(CGFloat)width
needs to resign itsdispatch_once
block. The static UITextView object would make useless a subclass override of+ (UITextView *)textViewForSizing
. This last method is now responsible of thedispatch_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.