UIPickerView:旋转时获取行值? [英] UIPickerView: Get row value while spinning?
问题描述
我想实时获取行值,因为iPhone用户在UIPickerView中旋转一个轮子(不仅仅是当轮子安装到特定行时)。我查看了子类化UIPickerView然后重写了mouseDown方法,但我无法使其工作。任何建议都将非常感激。
I'd like to get the row value in real-time as the iPhone user spins a wheel in a UIPickerView (not just when the wheel settles onto a particular row). I looked into subclassing UIPickerView then overriding the mouseDown method, but I couldn't get this to work. Any suggestions would be very much appreciated.
推荐答案
也许尝试实现委托方法:
Perhaps try implementing the delegate method:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
您可以将其视为直通(只是传回reusingView参数),但每次调用它时您都会知道该视图当用户滚动时,屏幕上出现了 - 然后你可以计算从中心视图偏移的视图数量。
You could treat it as a passthrough (just passing back the reusingView parameter) but each time it was called you would know that view was coming on the screen as the user scrolled - then you could calculate how many views offset from this one the center view was.
这篇关于UIPickerView:旋转时获取行值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!