我打算讓控件一開始就選中某個日期,我使用了下面的方法。
- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated
按照我自己的理解,此時應該會去執行代理方法:
- pickerView:didSelectRow:inComponent:
,然而實際運行時發現,代理方法並沒有觸發,結果我在設置了滾動到的位置后,必須主動調用代理方法。也就是下面這樣:
[self.picker selectRow:0 inComponent:0 animated:YES]; [self pickerView:self.picker didSelectRow:0 inComponent:0];