1

I have a simple UITableView that I've added a UIButton to the Footer.

Similar to this:

self.btn =[UIButton buttonWithType:UIButtonTypeCustom];
self.btn.backgroundColor = darkPurple;
[self.btn setTitle:@"Submit" forState:UIControlStateNormal];
[self.btn addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.btn.frame=CGRectMake(0, 0, self.tableView.frame.size.width, 100); 
self.btn.showsTouchWhenHighlighted = true;
self.tableView.tableFooterView = self.btn;

Sometimes when I get scrolled to the bottom of the TableView if it isn't completely settled the Button won't perform the action. Sometimes it will flash (showsTouchWhenHighlighted) but I'll need to tap it again.

What am I missing here? I've tried solutions like this but it doesn't appear to work.

UIButton touch is delayed when in UIScrollView

I want to it process always, even if the scroll isn't settled and not delay.

Community
  • 1
  • 1
aherrick
  • 19,799
  • 33
  • 112
  • 188

1 Answers1

1

What am I missing here?

Nothing. That's just how touches work on iOS. You can see the same thing in Mobile Safari: if the page is still scrolling, tapping a link doesn't work. You have to wait until the page is completely stopped ("settled", as you rightly say).

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thanks for the response. So there is no way to disable this? It's annoying to have the button "flash" and then have nothing happen. – aherrick Mar 17 '16 at 15:45
  • I agree. I think that happens because the button "eats the touch" while the scroll animation is going on. (That phrase comes from an Apple WWDC video from some years ago.) You _might_ be able to work around this by putting a UITapGestureRecognizer on the button. Be careful because you then have to mediate between whether it is the button itself or the gesture recognizer that is responding. – matt Mar 17 '16 at 15:47
  • Matt, can you explain? I've added a UITapGestureRecognizer instead and its performing the exact same way. Thanks! – aherrick Mar 18 '16 at 14:24
  • I didn't say the tap gesture recognizer trick would work, I said it _might_ work. I've never tried it. – matt Mar 18 '16 at 14:33