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?
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??
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.