nicklockwood / FXForms

[DEPRECATED]
Other
2.93k stars 339 forks source link

FXFormFieldTypeLongText size calculation is off #87

Open ishaq opened 10 years ago

ishaq commented 10 years ago

how to reproduce:

@interface Bug : NSObject <FXForm>
@property (nonatomic, strong) NSString *longText;
@end

@implementation Bug
- (id)init
{
    if((self = [super init]))
    {
        self.longText = @"This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text \
                    This is a long text, this is a long text\n \
                    This is a long text, this is a long text";
    }
}

- (NSArray *)fields
{
    return @[{FXFormFieldKey:@"longText", FXFormFieldType: FXFormFieldTypeLongText, FXFormFieldPlaceholder:@"Placeholder..."}];
}
@end

to show the form:

FXFormViewController *controller = [[FXFormViewController alloc] init];
controller.formController.form = [[Bug alloc] init];

you'll notice that size of the text view bigger than required for the string. In a live scenario where user had typed a few paragraphs and returned to edit them later, the size was a little smaller (hiding the last quarter of the text). This combined with #86 creates editing nuisance.

hanneskaeufler commented 10 years ago

I can confirm this as well. The cell grows larger than the input text would require.

hanneskaeufler commented 10 years ago

I think this happens because the calculation does not user the correct fontSize here: https://github.com/nicklockwood/FXForms/blob/master/FXForms/FXForms.m#L2647 Maybe the set font should be considered here?