CyReX
CyReX

Reputation: 1576

Switching 2 UIPickerview's component each other

I am going to ask weird question.

I have a 1 UIPickerView with 2 components. I am using it for translation UI in order to users can choose source and target language via UIPickerView.

What I am gonna ask you ; when user tap on switch button, souce and target language UILabel's are switching each other as expected. In order to stay logic in UX , i need to change UIPickerView's component as well .

This is the first step of switching label's which passed value from PickerView :

Switching Language source and target labels

Switching Language source and target labels

Second step expecting to PickerView components changed each other too .

Component's need to switch each other

How can i succeed it ? Any help will be appreciated.

Regards,

Önder.

Upvotes: 1

Views: 122

Answers (2)

[picker selectRow:0 inComponent:0 animated:YES];

Upvotes: 1

dmerlea
dmerlea

Reputation: 936

Use the UIPickerView method

SWIFT

func selectRow(_ row: Int,
   inComponent component: Int,
      animated animated: Bool)

OBJECTIVE-C

- (void)selectRow:(NSInteger)row
      inComponent:(NSInteger)component
         animated:(BOOL)animated

This should animate pickerView for each component at the row you need animated.

Upvotes: 1

Related Questions