Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISegmentedControl delegate/Touch Events

I have a UISegmentedControl that has six segments, I want them to call a method when the value changes, but also when each segment gets a UIControlEventTouchDragIn because I want a UILabel to show up with it's name when the person is trying to select something on it and drags their finger across the control, but the segmented control does not sen this call even when I drag into the thing. Please help. Maybe I need to create UIButtons over the control that call methods upon a drag in, but call the value changed method when they recieve a tap.

like image 859
Jab Avatar asked Jan 13 '10 13:01

Jab


1 Answers

Maybe I don't understand your question correctly but couldn't you just use this:

[segmentedControl addTarget:self 
         action:@selector(action:)  
         forControlEvents:UIControlEventValueChanged];

and just replace the UIControlEventValueChanged by UIControlEventTouchDragIn? Then in your action method do whatever needs to be done such as changing the text of a UILabel.

I have a UITAbleView with a bunch of cells and an UISegmentedControll in each cell and it works just fine for me.

The documentation for UISegmentedControl seems to be unavailable online but you can see it in XCode's Organiser and the code above is the first example.

like image 144
Deratrius Avatar answered Oct 26 '22 23:10

Deratrius