gpt4 book ai didi

objective-c - 从 UIGestureRecognizer 中排除表格以隐藏键盘

转载 作者:行者123 更新时间:2023-12-03 16:38:09 27 4
gpt4 key购买 nike

当用户点击文本字段之外时,我使用 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;
}

如何排除表格?

最佳答案

我还没有找到问题的答案,但我确实找到了一种可以满足我需要的解决方法。我没有尝试找出如何排除表,而是做了相反的事情。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if (touch.view == [self view])
{
return YES;
}
return NO;
}

关于objective-c - 从 UIGestureRecognizer 中排除表格以隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10366612/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com