Question

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];
    NSLog(@"Test");
}

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 :)

Was it helpful?

Solution 2

I figure out by checking the option Momentary. Thanks

enter image description here

OTHER TIPS

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

Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top