views:

68

answers:

1

How are the user's touches detected if i were to use UILabels that are overlayed on each picker component? I understand how to detect the user's touches on the picker, but I need to update the text of the label after the user make changes a picker component value. My method is not being called after I change the values in the picker components. Any suggestions?

A: 

What are you trying to do that can’t be accomplished just using a UIPickerView? In its UIPickerViewDelegate, when you receive the -pickerView:didSelectRow:inComponent: message, you can call [pickerView reloadComponent:someComponent]; to change the contents of a given row based on the user’s selections.

Jeff Kelley
i am using a UIPickerView. tried using a method that would check if (x.touchInside) then set a flag and change the text of the overlying UILabel, but my method does get called after i select a different value in the underlying picker.
yellahd
...i think i have defined my struct correctly. i can step through the line of code, but not able to detect a user's touch.
yellahd
I will try to place my block of code in didSelectRow. Just not sure how to detect the user's response since touchinside events are not pressent for UILabels
yellahd
Why do you need to detect a touch on the `UIPickerView`? Its touch code is all built in. You might consider updating your original question with screenshots to help illustrate the problem you’re having.
Jeff Kelley
i am wanting the UILabel text update to occur each time the user changes a selection.
yellahd
Every time the user changes the selection in the `UIPickerView`, that picker view calls the equivalent of `[self.delegate pickerView:self didSelectRow:self.selectedRow inComponenet:self.selectedComponent];`. Put your label-changing code in that method in its delegate and you’re all set.
Jeff Kelley
Interesting...i had didSelectRow commented out before i received your last comment. And, i have noticed that after uncommenting it this method is still not being called. I was thinking this method should be called each time i select a value in the picker.
yellahd
Did you ever set the delegate? Something like `[pickerView setDelegate:self]` in whatever class you’re using as the delegate.
Jeff Kelley
appears i didn't. attempting to set at the moment. i remember didSelectRow working before. interesting...
yellahd
i am receiving an error "expected specifier-qualifier-list before'[' token" after i added your suggested line of code
yellahd
i was thinking that the setDelegate method was expecting a class name. not an instance of the class. Got confused.
yellahd