gpt4 book ai didi

ios - UIView 与 UITableView 和 UIGestureRecognizer 突然停止手势识别

转载 作者:行者123 更新时间:2023-11-29 04:12:52 25 4
gpt4 key购买 nike

我的应用程序有一个包含 UITableView 的 View 。我向 View 添加了一个 UIPanGestureRecognizer 。我使用 GestureRecognizer 来调整 TableViews 宽度。

调整 TableView 的宽度时,表格内的单元格也会自动调整大小。

首先,这非常有效。 - 调整大小后,GestureRecognizer 突然不再触发。在另一个 View 区域(tableView 除外)内,GestureRecognizer 仍然可以正常工作。

如果我旋转设备,GestureRecognizer 会再次开始工作一段时间。

我也有同样的情况,使用 UICollectionView 而不是 TableView - 一切正常。

有解决问题的提示吗?

最佳答案

我想出了以下方法,这对我来说效果很好。

我将 UIGestureRecognizerDelegate-Protocol 添加到我的 ViewController 中,并添加了以下函数:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}

关于ios - UIView 与 UITableView 和 UIGestureRecognizer 突然停止手势识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14163319/

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