2

こんにちは、UIPickerview 行にテキストを表示しています。しかし、ラベルのサイズが大きすぎると、ピッカー行が表示されます... ラベルの最後に。

これではなく、ピッカーの行にタイトル全体を表示したい。ピッカービューでタイトルの幅に合わせてフォント サイズを自動的に設定できますか。

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 に答える