UIPickerView的selectRow:inComponent:animated:call pickerView:didSelectRow:inComponent:?

时间:2011-08-09 19:23:08

标签: uipickerview

UIPickerView的selectRow:inComponent:animated:是否致电pickerView:didSelectRow:inComponent:? 否则,我可以自己打电话吗?

由于

3 个答案:

答案 0 :(得分:24)

您必须手动调用它,并通过代理执行此操作。

// In this example the UIPickerView object is in a property
...
self.pickerView.datasource = self;
self.pickerView.delegate = self;

// Selects the row in the specified component
[self.pickerView selectRow:0 inComponent:0 animated:NO];

// Manually calls pickerView:didSelectRow:inComponent:
[self pickerView:self.pickerView didSelectRow:0 inComponent:0];

答案 1 :(得分:4)

虽然可以手动调用,但它没有。

答案 2 :(得分:1)

它也没有用swift调用委托方法,但你也可以手动完成。决定 swift 3 swift 4

self.pickerView.datasource = self
self.pickerView.delegate = self

self.pickerView.selectRow(0, inComponent: 0, animated: false)
self.pickerView.delegate?.pickerView?(self.pickerView, didSelectRow: 0, inComponent: 0)