我有我的viewController幾個UIPickerViews。幾個UIPickerView
這是其中的一個需要定製,因爲它在1個選取器行中顯示2個UILabel。
而且我使用這些委託方法:
- (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種方法一起,第二個總是被調用,第一個似乎從未被稱爲,
它導致我的特殊選擇器顯示正確的數據,但其他人什麼也沒有。
我該怎麼做?
如果我在第二種方法中給出所有采集器的數據,那麼reusingView會成爲一個問題,因爲特殊採樣器的reusingView與其他採集器的格式不同?
非常感謝!
有趣...你是否在第二種方法中返回其他採樣器的nil? – govi 2012-02-22 11:13:32
是的,那會是問題嗎?如果我不返回任何內容,將會有警告,所以...我會立即嘗試刪除該代碼。 – 2012-02-22 11:17:20
好..沒有。你不必刪除那條線,這很好。 – govi 2012-02-22 11:24:56