joshim5
joshim5

Reputation: 2255

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

Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent:? Otherwise, can I just call it myself?

Thanks

Upvotes: 14

Views: 6093

Answers (3)

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)

Upvotes: 1

Matt Tang
Matt Tang

Reputation: 1297

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

Upvotes: 26

joshim5
joshim5

Reputation: 2255

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

Upvotes: 5

Related Questions