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?
views:
68answers:
1
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
2010-07-12 18:17:22
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
2010-07-12 18:32:25
...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
2010-07-12 18:35:13
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
2010-07-12 18:44:13
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
2010-07-12 19:17:55
i am wanting the UILabel text update to occur each time the user changes a selection.
yellahd
2010-07-12 23:01:22
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
2010-07-12 23:37:57
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
2010-07-13 12:37:37
Did you ever set the delegate? Something like `[pickerView setDelegate:self]` in whatever class you’re using as the delegate.
Jeff Kelley
2010-07-13 13:48:02
appears i didn't. attempting to set at the moment. i remember didSelectRow working before. interesting...
yellahd
2010-07-14 11:10:42
i am receiving an error "expected specifier-qualifier-list before'[' token" after i added your suggested line of code
yellahd
2010-07-14 11:37:38
i was thinking that the setDelegate method was expecting a class name. not an instance of the class. Got confused.
yellahd
2010-07-14 12:03:09