私はいくつかのUIPickerViewをviewControllerに持っています。複数のUIPickerView
これは、1つのピッカー行に2つのUILabelsを表示するため、カスタマイズする必要があります。
そして私は、これらのデリゲートメソッドを使用します。
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row
forComponent:(NSInteger)component {
// this method is use for normal pickers, and I would judge whether the picker that calling
// this method is a normal one or the special one by pickerView.
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view {
// and this one is specially for the special picker, I would also judge the pickerView is
//normal or special, if pickerView is normal, return nil, else I return a UIView with
//2 UIlabels.
}
しかし、今、私のデバッグの後、私は一緒に2つの方法を実装する場合、二つ目は常に呼ばれていることを発見し、最初のものが呼び出されないことを決して思わ、
となり、私の特別なピッカーは正しいデータを表示しますが、他には何もありません。
どうすればいいですか?
2番目の方法ですべてのピッカーのデータを与えると、特別なピッカーのreusingViewは他のピッカーと同じ形式ではないので、reusingViewは問題になりますか?
ありがとうございます!
興味深いのは... 2番目の方法では他のピッカーのためにnilを返しますか? – govi
はい、それは問題でしょうか?私が何かを返さなければ、警告が出るので、すぐにそのコードを削除しようとします。 –
よく分かりません。あなたはその行を削除する必要はありません、それは完璧です。 – govi