简体   繁体   中英

UISlider thumb stops dragging

I have a UISlider in a view, in a typical detail View Controller. When I touch the slider's thumb, I can drag it to the left fine, and once I've dragged it left, I can continue to drag it wherever I want, but when I drag it right, it moves a few pixels and then the drag stops.

I read at UISlider only slide a small distance that it may be related to gesture recognizers, but I don't have any recognizers active in this view. I've tried temporarily removing any recognizer that might interfere, but that didn't help.

I don't have any sample code to include because there's really not much code involved in the case I'm having trouble with. I have a UIViewController subclass that has a UISlider on it, and I have an IB-generated action for the "Value Changed" event. This fires, and as I said, I can drag the slider left, but not right.

I tried changing the action so all it does is NSLog the slider's value, and that doesn't help.

I expect the problem is some interaction withs something else in the app I'm working on, but I'm not sure where to look. I'm looking for some ideas as to what could be causing this.

Update

So I found the problem. It's a bug in iOS 5.1, described in iOS 5.1 swipe gesture hijacked by UISplitViewController - how to avoid? .

I tracked it down by enumerating all the gesture recognizers (by walking the view hierarchy from self.view.window and dumping them) and then selectively removing them, then Googling on the one that ended up causing the problem. Pain in the butt. Leaving this here for the next victim.

I posted the answer as an update to the question, but in a nutshell, it's an iOS 5.1 bug. The pan gesture recognizer for the split view controller is interfering with the slider. My workaround is to disable that recognizer.

You are probably trying to increase the value of the slider to something greater than 1. You need to enter a float between 0 and 1, such as 0.46.

Look through the part of the code where you update the value and check that.

Short answer:

Try setting slider's propery continuous to NO .

Long answer:

I encountered a similar problem: slider's thumb would not move on iPad 5.1 Simulator. No problems on iOS 6 though. In my case, I was setting slider's minimumValue and maximumValue to some other values in code. The problem disappeared after I set continuous property to NO . The relevant fragment of code:

            self.precisionSlider.minimumValue = 0;
            self.precisionSlider.maximumValue = 15;
            self.precisionSlider.continuous = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM