3

here's an odd one..

I've got a UIView xib file that looks like this:

enter image description here

I've connected every UIButton touchDown and touchUpInside events to two IBAction methods:

- (IBAction)touchUpInside:(id)sender
{
    NSLog(@"touch up inside");
    if (((UIButton *)sender == _enter) | ((UIButton *)sender == _back)) {
        [(UIButton *)sender setBackgroundColor:_color2];
    }
    else {
        [(UIButton *)sender setBackgroundColor:_color1];
    }
}

- (IBAction)touchDown:(id)sender
{
    NSLog(@"touch down");
    [(UIButton *)sender setBackgroundColor:_color2];
}

Everything works except for the bottom-most row of UIButton's, that's the odd part:

The touch down event is fired, but the button must be held for 0.5 second for it to change background color, whereas it is instantaneous for the other buttons.

It ONLY happens for the bottom-most row of UIButton's, as I've tried to switch buttons 7, 8, 9 with buttons @back, 0, @enter like this:

It is always the bottom-most row of <code>UIButton</code>'s that show the touchDown delay

I've checked in Interface Builder all the UIButton attributes are the same, and I've tried moving the UIButton's objects order around as you can see on the left side of the picture, and I'm about out of ideas already. Basically what's odd is the UIControl behavior differs based on its position on the parent view...

UPDATE: I made the parent UIView height value large enough that there is 50 free pixels below the last row and the UIButton's work fine now. The only reason I can think of now is that there is a UITabBar there 2 view controllers level underneath. Even so it doesn't make sense.

Kampai
  • 22,848
  • 21
  • 95
  • 95
JackyJohnson
  • 3,106
  • 3
  • 28
  • 35

1 Answers1

2

The document says:

Expect users to swipe up from the bottom of the screen to reveal Control Center. If iOS determines that a touch that begins at the bottom of the screen should reveal Control Center, it doesn’t deliver the gesture to the currently running app. If iOS determines that the touch should not reveal Control Center, the touch may be slightly delayed before it reaches the app.

One solution is here: UIButton fails to properly register touch in bottom region of iPhone screen

But, in your case, I think you should use inputView in UIResponder.
See: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html

The inputView is not affected by that problem.

Community
  • 1
  • 1
rintaro
  • 51,423
  • 14
  • 131
  • 139
  • okay, that makes sense... though I didn't expect inputView doesn't have the problem, but inputAccessoryView does. Thanks! :) I guess another thing is that inputView is constricted to be 215 pixels high, inputAccessoryView is pretty much anything. – JackyJohnson Jul 31 '14 at 15:18