SpaceDog SpaceDog - 4 months ago 12x
Objective-C Question

UIPickerView: select one element after the other finishes animation

I have a

with two elements: months and days. I am doing this

[self.picker selectRow:3 inComponent:0 animated:YES];
[self.picker selectRow:10 inComponent:1 animated:YES];

This makes both elements to roll to the selected items.

But In fact what I want to do is to roll the first element and then, when the first element finishes rolling, roll the second element.

I can do a dispatch after delay but this is a hack.

Is there any way to know when the first animation ends and then trigger the second?


Implement the delegate method pickerView:didSelectRow:inComponent:.

Call selectRow on the fist picker, then when didSelectRow is called with row 3 for the first picker, call selectRow on the second picker.