0

私はiphoneを初めて使用します。ピッカービューに少し疑問があります。ピッカービューで行を選択すると、ピッカービューを取り、そこにデータを保存します。その行のテキストは、配置したuibuttonに表示する必要がありますが、問題テキストの最初の 3 文字のみが表示されます。なぜこれが私が書いた以下のコードなのかわかりません

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    if([pickerView isEqual:selectBookPickerView]){
    NSString *booksTitle = [[NSString alloc] initWithFormat:@"%@",[booksArray objectAtIndex:row]];
    selectBook.titleLabel.text = booksTitle; 
    }
    else
    {
    NSString *chapterTitle = [[NSString alloc] initWithFormat:@"%@",[chaptersArray objectAtIndex:row]];
        startChapter.titleLabel.text = chapterTitle; 

    }
}
4

1 に答える 1

0

簡単な解決策は、次のコードを if ステートメントの後に置くことです。

[selectBook sizeToFit]

これにより、ボタンがテキストのサイズに自動的に調整されます。

于 2012-05-23T22:42:54.190 に答える