8

I have a UIButton on the far left of a view controller (on a XIB), of say 100 points wide.

If the view controller is on a regular tab (i.e. not pushed on navigation stack) the button highlights as expected when tapped.

However, when the view controller is on a More-tab (so pushed on the navigation stack), the button is not highlighted when tapped on its left side (say the left most 50 points). The button does function, it's action is being called. But, when tapped on the right side it does highlight. (BTW, I think this is a general issue when the view controller is pushed from any other view controller; does probably not have to be More tab.)

After some research it turns out it's when I tap in the left screen area with which you can iOS-7-slide back to the parent view. Any ideas why this is, and how to make the button work properly again.

Thanks for your time!

meaning-matters
  • 21,929
  • 10
  • 82
  • 142
  • 1
    I can readily reproduce this in a no-code app, so you don't need all that "highlighted" and "drawRect" stuff at all. - I'm investigating now to see if it's just a Simulator bug. Have you tried this on a device? – matt Feb 24 '14 at 21:45
  • @matt I'm always using the device, so yes. iOS 7.0.6. Thanks man! – meaning-matters Feb 24 '14 at 22:35
  • 1
    Confirmed on a device as well. Looks like you've got yourself a system bug. I suggest you report it. – matt Feb 24 '14 at 22:35
  • @matt Was that pushed from a regular view controller, or from More? – meaning-matters Feb 24 '14 at 22:38
  • Regular view controller, pushed onto a navigation stack. As you say, the draggable area from the left side seems to be what's interfering. It interferes with the highlighting but not the tap. – matt Feb 24 '14 at 22:42

2 Answers2

4

I can confirm this bug with almost no code at all. All you need is an image file to serve as the background image. In the storyboard set this up:

Navigation Controller -> (root view controller) ViewController -> Button -> push segue... ->
ViewController2 -> Button

Put the second button up against the left side of its containing view (ViewController2's view) and set the image file as its highlighted background image.

Now run the app and tap the first button, to summon the second view controller's view. Tap the button at its right side: the highlighted background image appears. Now tap the button at its left side: the highlight background image does not appear, but the button is in fact receiving the tap (you can confirm that by giving it an action method that logs).

So, I would say you've got yourself a legitimate bug and you should report it to Apple. I'm certainly going to!

matt
  • 515,959
  • 87
  • 875
  • 1,141
3

Unless you require the iOS 7 swipe-to-pop gesture, you can fix this bug by disabling that gesture recognizer:

self.navigationController.interactivePopGestureRecognizer.enabled = NO;
hwaxxer
  • 3,363
  • 1
  • 22
  • 39