Search code examples
uitableviewios6scrollios7uisegmentedcontrol

How to prevent scrolling on table view from registering taps to seg control on iOS 7?


I have a tableview with a UISegmentedControl as a subview on each row (cell). Before iOS 7 I could scroll up and down freely without any finger contact being interpreted as a tap on a segment. Now, only on iOS7, I cannot scroll without unwanted firing of setSelectedSegmetIndex. If the user is not paying attention they unknowingly change settings when simply intending to scroll. Any way to prevent this? I am using Xcode 5 targeting iOS 6 builds, and bc of our customer base need to be able to do this, since some will not have upgraded. If I target iOS 7 things work as usual, it only seems to be when iOS 6 targeted builds are run on a device upgraded to iOS 7.


Solution

  • This is indeed a bug, and it seems clear that Apple is not going to do anything to address it. In iOS 7 UIButton and UISegmentedControl objects placed on UITableViewCell objects will interpret user touches intended as swipes as taps (selections) This was not the case with iOS 6. Here's the vague, non-commital reply I received back from the Apple engineer: "After some investigation there indeed appears to be several changes within iOS 7 in how controls within UITableViewCells interact with gesture recognizers. For iOS 7 the table view is making its best attempts to mediate or allow controls like sliders and segmented controls to have a higher propiority over gesture/touch events. So this behavioral change doesn't appear to be customizeable, at least not allowing to revert back to the older behavior in iOS 6." My intention is not to besmirch Apple's reputation here. The previous times I've worked with their engineers they made determined efforts to figure out if their code was the cause, and admitted it clearly if so, offering help for workarounds.