3lvis / Form

The most flexible and powerful way to build a form on iOS

Home Page:http://hyper.no

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing width/height of "select" type

RyanKim01 opened this issue · comments

Hi,

My popover for "select" type contains a long sentence. Thus, the popover does not show full sentence.
(1) Is there a way to manipulate the width of it?

screen shot 2015-12-29 at 4 31 51 pm

As you can see from the image, it only shows small portion of a sentence in the popover.

(2) Moreover, is there a way to expand high of textfield for "select" type to show a full sentence without cut like below image??
screen shot 2015-12-29 at 5 04 30 pm

Hi @RyanKim01, I guess we could have done dynamic height instead of fixed height on those cells. It wasn't a requirement for us at that moment.

At the moment this doesn't work out of the box, feel free to add this change and submit a pull request.

Best,

@3lvis , I was looking into it and faced some problems.
In FORMFieldValuesTableViewController.m, I see tableview row height is fixed as 44. self.tableView.rowHeight = 44.
(1) I think I first need to come up with a way to show a long sentence in multiple lines. I confirmed that only one line is shown in popover even if row height is increased. However, I could not find where I could modify this.
(2). If (1) is solved, I was thinking about setting row height as self.field.size.height.
Would this work?

If you can give me some thoughts on those, I would really appreciate it.

You can use:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

To set the height of the cell. Then you can use something like this to get the height of text.

@implementation NSString (Sizes)

- (CGFloat)heightUsingFont:(UIFont *)font andWidth:(CGFloat)width {
    NSDictionary *attributes = @{ NSFontAttributeName : font };
    CGRect rect = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX)
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                  attributes:attributes
                                     context:nil];
    return CGRectGetHeight(rect);
}

Finally you can change the numberOfLines attribute on a UILabel to say how many lines the cell should have, this can be dynamic too, if you know the height of one line.

There might be better ways but that's what comes to my mind right now.

@3lvis , Just made a pull request on this issue.