1

I have 3 buttons on one View of UIViewController. On each button click event i called same picker view with different object values.

how to set the selection indicator on last object index for particular button.?

Wise
  • 49
  • 1
  • 5

3 Answers3

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

Selects a row in a specified component of the picker view.

Source

Alexander
  • 8,117
  • 1
  • 35
  • 46
0

In button click event you can make use of this.

  1. selectRow:inComponent:animated: - Helps you select particular row in the picker.

  2. numberOfRowsInComponent: - Returns the count of rows in the particluar component.

So inorder to select the last object index, you can make use of this.

[self.pickerView selectRow:[self.pickerView numberOfRowsInComponent:0] inComponent:0 animated:NO];
Vinayak Kini
  • 2,919
  • 21
  • 35
0

You can do this using following snippet

[self.pickerView selectRow:MAX_VALUE inComponent:0 animated:NO];

where MAX_VALUE = total no. of rows in component - 1;

Enjoy Programming !!

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34