UIPickerView stuck between rows?

I noticed a problem when using UIPickerView, and I wonder if anyone has met before: sometimes, while scrolling through one of the wheels, it gets stuck between two rows (after the finishing touches) and just stays like that endlessly. Dragging the wheel again a bit and releasing always fixes the problem, but regardless, I'm puzzled as to why this happens in the first place. This happens when testing both in the simulator and on the device itself.

The problem is not so much in the annoyance of having to reinstall the wheel when it gets stuck, but in the fact that sometimes it gets stuck when it is very close to selecting a row (but actually did not select it), which can give the user the impression that they have selected line when really not.

Has this happened to someone else, and if so, is there a way to fix this?

Thanks,

Chris

+4
source share
4 answers

Still could not find a good way to solve this problem ... the best decision that I could think of is to include the following line in the method pickerView:didSelectRow:inComponent: :

 [pickerView selectRow:[pickerView selectedRowInComponent:0] inComponent:0 animated:YES]; 

This will roll back the specified component in the correct line, ensuring that the user always sees the exact idea of โ€‹โ€‹what is selected, but sometimes it seems strange when you think that the component stops on a specific line, only to see how it moves backward direction before stopping.

+2
source

I had a very similar question. UIPickerView will scroll and pause between lines. Usually this view does not stop between lines, which will scroll to the next line, even if you try to stop it between two elements. I have many applications that did not display the problem, although they used the same code to instantiate the UIPickerView.

After much research, I found that the problem was with processor usage. My application is an OpenGL game, so I have a game loop that runs as fast as possible to update frames. Admittedly, my game was connected to the processor and did not reach the full frame rate. I left the game running in the background while pickerView popped up so that the user could make a choice. This did not seem to leave the CPU for the UIPickerView to detect that it had stopped between the lines and was pulling itself to the nearest line.

My simple solution is to pause the game while the kind of choice is in.

I see that this answer was a year late, but it took me a while to figure out, so that it helps someone.

+1
source

I think I figured it out. When the idea that you are using UIPickerView in loads, you need to set the delegate of collectors, for example:

 picker.delegate = self; 

This should fix the problem and force the collector to automatically center on the value, rather than float between the lines.

0
source

you should check subviews frames in the pickerview delegate method (pickerView: viewForRow: forComponent: reusingView :). frame height should not exceed the content presentation height.

0
source

All Articles