2

Hello friends I am displaying text in UIPickerview row. But when the label size is too big then Picker row displays ... at the end of the label.

I want to display whole title in row of Picker instead of this. Can i set the font size automatically as per the title width in pickerview.

Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
  • I did not clear ida about this, but once go through this link, http://stackoverflow.com/questions/5038891/center-uipickerview-text – Friend Aug 30 '13 at 05:15

2 Answers2

2

You need to implement following method:

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

    UILabel* tView = (UILabel*)view;

    if (!tView){

        tView = [[UILabel alloc] init];

        // Setup label properties - frame, font, colors etc
        ...
    }

    // Fill the label text here
    ...
    return tView;
}
CRDave
  • 9,279
  • 5
  • 41
  • 59
Satish
  • 1,012
  • 2
  • 15
  • 32
1

Make your controller a UIPickerViewDelegate and UIPickerViewDataSource, then you can use this routine to make any custom change you want for your picker row:

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

//make your own view here, it can be a UILabel if you want, or other kind of view.

//You can give it any size font you need.

}
HalR
  • 11,411
  • 5
  • 48
  • 80