2

你好朋友我在 UIPickerview 行中显示文本。但是当标签尺寸太大时,Picker 行会在标签末尾显示 ...。

我想在 Picker 行中显示整个标题而不是这个。我可以根据pickerview中的标题宽度自动设置字体大小吗?

4

2 回答 2

2

您需要实现以下方法:

- (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;
}
于 2013-08-30T05:34:42.583 回答
1

使您的控制器成为 UIPickerViewDelegate 和 UIPickerViewDataSource,然后您可以使用此例程对您的选择器行进行任何您想要的自定义更改:

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

}
于 2013-08-30T05:17:26.840 回答