I am having a UITextField
and replacing iPhone keyboard with UIPickerView
having 3 to 4 components in a row, the problem i am fac开发者_Python百科ing is that when i move values of 3 or 4 components faster as much as i can the event - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
is fired one, and only value of just one component is updated which was selected at last. How can i fix it ? is there any method other than - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)
component to overcome this problem?
thanks
problem can be solve using if conditions. like:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(component == 0)
{
}
if(component == 1)
{
}
if(component == 2)
{
}
}
Zohaib, if I understand correctly you're scrolling through 3 or 4 components very quickly is it? The method - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
as far as I know is fired when a row is actually selected, i.e. a scroll ends at this particular row and it is therefore 'selected'. So, I'd assume its correct in being called only once. I assume you're not scrolling-then-stopping and doing that several times?
I faced the same problem of having multiple components scrolling at the same time, in the end only one selected value is detected.
I found a solution mentioned by someone in Apple discussion.
- (NSInteger)selectedRowInComponent:(NSInteger)component
Instead of relying on the row component value return by the picker, use above method to find each selected value in your picker and update accordingly.
Hope it helps
This is a problem with iOS 7. I was able to reproduce this in a test app with a picker with only 1 component. The trick is to get the picker going really fast so there's a big bounce at the end (sometimes a double or triple swipe is needed). It only happens about 1 time in 10 and I can't seem to get it to happen on the iPhone. I have however seen it on both the simulator in Xcode 5.0 and my iPad mini with Retina Display running 7.0.6.
https://dl.dropboxusercontent.com/u/36715615/UIPickerViewTest.zip
精彩评论