拖动 UITableView

发布于 2025-01-02 19:04:04 字数 664 浏览 2 评论 0 原文

我有一个小问题,我尝试拖动 UITableview,在这段代码中我拖动了视图,但无法拖动 uitableivew,问题出在哪里?

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.table addGestureRecognizer:panGesture];

- (void)handlePan:(UIPanGestureRecognizer *)recognizer {

    CGPoint translation = [recognizer translationInView:self.view];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
    [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
    [self.view bringSubviewToFront:recognizer.view];

}

我使用 iPad 应用程序工作

I have a little problem, I try to drag a UITableview, whit this code I drag a view but I can't drag a uitableivew, where is the problem?

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.table addGestureRecognizer:panGesture];

- (void)handlePan:(UIPanGestureRecognizer *)recognizer {

    CGPoint translation = [recognizer translationInView:self.view];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
    [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
    [self.view bringSubviewToFront:recognizer.view];

}

I work on an iPad application

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘味果▽酱 2025-01-09 19:04:04

您的桌子会弹跳或滚动吗?那么这意味着你的桌子的滚动条受到了触摸,而你却无法得到它。观察表的滚动委托并在那里实现相同的代码。它会起作用的。

Does your table bounce or scroll? Then it means your table's scroll takes the touch and you won't get it. Observe your table's scroll delegate and implement the same code there. It will work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文