当用户在文本字段之外点击时,我正在使用 UIGestureRecognizer 退出键盘。这没有问题,我已经设法排除了 3 个按钮,但是现在我在页面中添加了 2 个表格,我找不到将它们从 shouldReceiveTouch 中排除的方法:
这是相关代码:
- (void)viewDidLoad
{
.....
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[[self view] addGestureRecognizer:gestureRecognizer];
[gestureRecognizer setDelegate:self];
}
- (void)hideKeyboard
{
[tradeQuantity resignFirstResponder];
[tradeSymbol resignFirstResponder];
[limitPrice resignFirstResponder];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if (touch.view == placeTradeButton)
{
return NO;
} else if (touch.view == resetValuesButton)
{
return NO;
} else if (touch.view == refreshDataButton)
{
return NO;
} else if (touch.view == secHoldingsTable)
{
return NO;
} else if (touch.view == tradeTicketsTable)
{
return NO;
}
return YES;
}
如何排除表格?