gpt4 book ai didi

ios - 触摸开始 : inside UITableView

转载 作者:行者123 更新时间:2023-11-29 02:16:49 26 4
gpt4 key购买 nike

我需要为作为 UITableViewCell 的 subview 添加的 UIView 实现拖放功能。我根据 Apple 的 MoveMe 示例使用 touchesBegan: touchesMoved: 事件捕获了拖动。

这是在单元格内添加的 View :

enter image description here

gradientview是cell的子view。我只需要移动白色矩形(白色框是橙蓝色渐变 View 的 subview )。我的问题是,在向上或向下拖动几个像素后,tableview 开始滚动。横向没问题。似乎 tableView 在一定数量的拖动后捕捉到拖动。在拖动进行之前,我需要阻止垂直滚动。

是否有解决方案来防止这种情况发生?

最佳答案

好的。我最终使用了 UIPanGestureRecognizer。这似乎挡住了下面的桌面 View 。

- (void)move:(UIPanGestureRecognizer*) recognizer {
CGPoint translation = [recognizer translationInView:self];
[recognizer setTranslation:CGPointMake(0, 0) inView:self];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);

关于ios - 触摸开始 : inside UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28659119/

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