Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPickerView - multi-line rows - need layout advice
    primarykey
    data
    text
    <p>I want to make picker with 2 lines, I tried it like <a href="https://stackoverflow.com/questions/15395813/uipickerview-using-custom-views-for-multi-line-rows-need-layout-advice">a link</a> , but I can not understand what I need to do: create a view and 2 label on it, when I add labels coordinates to code, but selection field still like it as default. How can I change selection field size? And text in selection field have bigger size when other lines. Sorry for my english.</p> <p><img src="https://i.stack.imgur.com/H3Gd8.png" alt="enter image description here"></p> <pre><code>- (UIView*)pickerView:(UIPickerView *)thePickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UIView* v; if (view) v = view; else { v = [[UIView alloc] init] ; UILabel* l1 = [[UILabel alloc] init]; l1.tag = 11; [v addSubview: l1]; UILabel* l2 = [[UILabel alloc] init]; l2.tag = 12; l2.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; [v addSubview: l2]; } UILabel* l1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 110, 35)]; l1.font = [UIFont systemFontOfSize:22]; // choose desired size l1.text = [NSString stringWithFormat: @"row %d line 1", row]; l1.tag = 11; [v addSubview: l1]; UILabel* l2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 34 , 110, 35)]; l2.font = [UIFont systemFontOfSize:14]; // choose desired size l2.text = [NSString stringWithFormat: @"row %d line 2", row]; l2.tag = 12; [v addSubview: l2]; return v; } </code></pre> <p>UPDATE</p> <pre><code> - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return yourViewHeight; } - (UIView*)pickerView:(UIPickerView *)thePickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UIView* v; if (view) v = view; else { v = [[UIView alloc] initWithFrame:CGRectMake(0, 34, 110, 35)] ; UILabel* l1 = [[UILabel alloc] init]; l1.tag = 11; [v addSubview: l1]; UILabel* l2 = [[UILabel alloc] init]; l2.tag = 12; l2.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; [v addSubview: l2]; } UILabel* l1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 110, 35)]; l1.font = [UIFont systemFontOfSize:22]; // choose desired size l1.text = [NSString stringWithFormat: @"row %d line 1", row]; l1.tag = 11; [v addSubview: l1]; UILabel* l2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 34 , 110, 35)]; l2.font = [UIFont systemFontOfSize:14]; // choose desired size l2.text = [NSString stringWithFormat: @"row %d line 2", row]; l2.tag = 12; [v addSubview: l2]; return v; } </code></pre> <p><a href="http://i.picresize.com/images/2013/12/11/IiYqd.png" rel="nofollow noreferrer">http://i.picresize.com/images/2013/12/11/IiYqd.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload