Handler tap of UISegmentControl to order data by ASC and DESC

I try to handler 2 tap on a UISegmentControl without success. I add a target to my listener with UIControlEventValueChanged and it work but only if the segment is not selected.

That my function that handle tap, the target is made with the storyboard:

- (IBAction)changeFilterAction:(UISegmentedControl *)paramSender {
    NSInteger selectedIndex = [_segmentControlFilter selectedSegmentIndex];

To resume:

I try to ORDERBY data by ASC and DESC. When i tap for the first time i post a ASC request and i would like that when i tap for the second time it post DESC request.

Any help would be appreciated :)


You will try to add Custom UIButton with clear color and place it to the UISegmentControl.

For Example :

UIButton * overButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, segControl.frame.size.width/numOfSegments, segControl.frame.size.height)];

[overButton addTarget:segControl action:@selector(overTapped:) forControlEvents:UIControlEventTouchUpInside];            

[segControl addSubview:overButton];

//Adjust your `overButton` frame as per your selected Segment index


I figure out by checking the option Momentary. Thanks

Need Your Help

finding a number in filename using regex

c# regex filenames

I don't have much experience with regexes and I wanted to rectify that. I decided to build an application that takes a directory name, scans all files (that all have a increasing serial number but ...

How do I append to each line of a .txt file using cmd across multiple files

batch-file command-line cmd windows-7

I have a large amount of .txt files residing in a single directory that have contents resembling the following...