[英]How to set selection indicator on passing object Index in picker View
I have 3 buttons on one View of UIViewController. 我在UIViewController的一个视图上有3个按钮。 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.? 如何在特定按钮的最后一个对象索引上设置选择指示器?
In button click event you can make use of this. 在按钮单击事件中,您可以利用它。
selectRow:inComponent:animated:
- Helps you select particular row in the picker. selectRow:inComponent:animated:
-帮助您在选择器中选择特定的行。
numberOfRowsInComponent:
- Returns the count of rows in the particluar component. numberOfRowsInComponent:
-返回特定组件中的行数。
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];
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 !! 享受编程!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.