我有一个简单的 UITableView,我已将 UIButton 添加到页脚。
类似于此:
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;
有时,当我滚动到 TableView 的底部时,如果它没有完全稳定下来,Button 将不会执行该操作。有时它会闪烁 (showsTouchWhenHighlighted
),但我需要再次点击它。
我在这里错过了什么?我已经尝试过类似的解决方案,但它似乎不起作用。
UIButton touch is delayed when in UIScrollView
我希望它始终进行处理,即使滚动没有解决并且没有延迟也是如此。
最佳答案
What am I missing here?
没有。这就是触摸在 iOS 上的工作方式。您可以在 Mobile Safari 中看到同样的情况:如果页面仍在滚动,则点击链接不起作用。您必须等到页面完全停止(“稳定”,正如您所说的那样)。
关于ios - UITableView 添加 FooterView 按钮有时点击不执行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36063442/