Heisenberg Heisenberg - 4 months ago 46
iOS Question

2 lines (multiline) picker for long text

why can i set the Row hight or multi lines for a picker,
the problem i have long texts for my picker, or gives an line break in picker... xcode 5 ...
i get the values for the picker from an array.
my code for my custom Picker is:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{

UILabel *label = [[UILabel alloc] init];
CGRect frame = CGRectMake(0,0,265,40);
label.backgroundColor = PickColor;
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18 ];
label.textAlignment = NSTextAlignmentCenter;

if(component == 0)
label.text = [_vergehen objectAtIndex:row];
return label;

thanks for help


Because you're creating a label, you might try this property of UILabel:

// UILabel wraps text across multiple lines
label.lineBreakMode = UILineBreakModeWordWrap;

If you set label.numberOfLines = 0, you should be able to get any number of lines placed within the label.