开发者

Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent:?

Does UIPickerView's selectRow:inComponen开发者_C百科t:animated: call pickerView:didSelectRow:inComponent:? Otherwise, can I just call it myself?

Thanks


You do have to call it manually and you do it though the delegate.

// 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];


It does not, although it is possible to call it manually.


It does not call delegate method with swift too, but you can do it manually also. Decision for swift 3 and 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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜