문제

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

도움이 되었습니까?

해결책 2

I figure out by checking the option Momentary. Thanks

enter image description here

다른 팁

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top