I have a view with UIPanGestureRecognizer and UISegmentedControl.

Segmented control has different styles for highlighted and selected state.

The problem is when I start pan gesture inside UISegmentedControl then it sometimes stays highlighted, but should be with selected style.

I tried to disable it when the touch is inside some area, but sometimes it still works.

How to solve this issue? It is clearly seen when segmented control has for example different font colors for highlighted and selected states.

有帮助吗?

解决方案

I think you should use this method to prevent touch on specific controls:(for example:)

- (BOOL) gestureRecognizer: (UIGestureRecognizer *) gestureRecognizer
       shouldReceiveTouch:(UITouch *)touch
{
    if (touch.view == sliderButton)
    {
        return NO;
    }
    return YES;
}

You can replace 'sliderButton' with your segment control or whichever view you want.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top