0

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.

Community
  • 1
  • 1
stevex
  • 5,589
  • 37
  • 52
  • Can you provide a project (github, dropbox) which demonstrates this behavior? – CodaFi Jul 03 '12 at 03:59
  • I have never experienced such problem, if it is a simple code then is it possible to upload the project in dropbox and share public link or probably github. – TeaCupApp Jul 03 '12 at 04:00
  • 1
    @CodaFi, Damn redundancy! lol – TeaCupApp Jul 03 '12 at 04:01
  • It's a fairly complex application, so I can't post the whole thing in GitHub, and the problem doesn't happen in a simple test app. Here's another piece of information: It doesn't happen on the iPhone, just the iPad. It smells like an interaction with a gesture recognizer but I've commented out all the gesture recognizers in the whole app, and still have the problem. Is there anything else that could interfere with the touch events the slider is receiving? – stevex Jul 03 '12 at 10:51
  • I just wrote some code to seek out and remove all gesture recognizers (basically walking UIViews from the root window and removing them all) and after I do this, the problem goes away. I can see there are quite a few gesture recognizers that I didn't install (or even recognize, like UIGobblerGestureRecognizer) that are likely UIKit internal. So now to figure out which one is giving me grief. – stevex Jul 03 '12 at 11:17
  • @stevex can you share the code of your solution. I have the same behavior on IOS8!!! – DaSilva Nov 13 '14 at 18:22

3 Answers3

1

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.

stevex
  • 5,589
  • 37
  • 52
0

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.

bkbeachlabs
  • 2,121
  • 1
  • 22
  • 33
  • I'm not currently setting the value to anything, so I don't think that would be the problem - also, the maximum defaults to 1.0 but I'm using a different value (2.0 in this case) so the value doesn't need to be less than 1.0. If the slider is in the middle of the range, and I grab it and drag right, it moves a tiny bit and then stops moving; but if I grab it and drag it left, it moves fine, including dragging to the right. – stevex Jul 03 '12 at 10:18
  • very strange. Post the code if you still need help. I'd be happy to look it over. – bkbeachlabs Jul 03 '12 at 16:31
0

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;
Maxim Chetrusca
  • 3,262
  • 1
  • 32
  • 28