UISwitch within UIScrollview nearly impossible to use

I'm using a UISwitch-Component at the bottom of a view that sits within a UIScrollView. Now the problem that appeared, is that the switch is nearly impossible to swipe because the UIScrollView seems to dominate the userinput.

Switching works very well by tapping the switch, but from my point of view, most users "switch" the UISwitch instead of tapping.

Did anyone of you face the same / or similar problems and managed to come up with a solution?

thx in advance



You have a design decision to make: if your content is meant to scroll horizontally, then a user swipe over a switch is ambiguous -- does it mean they want to scroll, or toggle the switch?

The easiest solution is to modify your UI so that this ambiguity disappears. For example, if the scroll's contentSize is not wider than the bounds of the scroll view, then it can't scroll horizontally, and a horizontal swipe will always activate the switch.

If you do want to allow horizontal scrolling, then it makes sense to replace the UISwitch with a UIButton that toggles on touch, similar to a play/pause button.

On the other hand, if you don't want to modify your UI, you could always just do:

myScrollView.delaysContentTouches = NO;

This will cause your switch to "get" the touches immediately, rather than have them go to the UIScrollView first. More info here. (You can also set this boolean in Interface Builder, as pointed out by Squeegy.)

Need Your Help

Security risks: when Low IL process is allowed to launch elevated services?

windows security com uac

Are there security risks, when a low integrity process is allowed to launch a medium/high integrity process via COM ?

Jedis "couldn't get pool resource" on a Storm topology

java redis apache-storm jedis bigdata

I have my topology running, every bolt works, except the redis bolt. I am trying just to write info to a redis database, and I have found an example online. The topology works, however, when the DB...