在pageViewController内的tableView上滑动以删除 [英] Swipe to delete on a tableView that is inside a pageViewController

查看:115
本文介绍了在pageViewController内的tableView上滑动以删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 pageViewController 中有一个 tableView ,当在一个单元格上滑动以显示该选项时为了删除单元格,手势只能在某些情况下被识别出来,比如你快速而且积极地滑动。

I've got a tableView inside of a pageViewController and when swiping on a cell to bring up the option to delete the cell the gesture is only recognized under certain circumstances, say you swiped very quickly and aggressively.

我想这会发生,因为它不确定滑动手势是否是适用于 pageView tableView 。有没有办法专门确定滑动手势的位置,以便能够顺利显示删除按钮?

I imagine this is happening because it's not sure whether the swiping gesture is meant for the pageView or the tableView. Is there a way to specifically determine where the swipe gesture is happening to enable a nice smooth display of the delete button?

推荐答案

我有同样的问题。我找到了一个运行良好的解决方案。

I had the same problem. I found a solution that works well.

把它放在你的 UIPageViewController viewDidLoad func。

Put this in your UIPageViewController's viewDidLoad func.

if let myView = view?.subviews.first as? UIScrollView {
    myView.canCancelContentTouches = false
}

PageViewControllers有一个自动生成处理手势的子视图。我们可以阻止这些子视图取消内容触摸。 tableview将能够捕获删除按钮的滑动,同时仍然可以解释将tableview的手势要求作为页面滑动失败的滑动。删除按钮将显示在您按住并滑动或猛烈滑动的情况下。

PageViewControllers have an auto-generated subview that handles the gestures. We can prevent these subviews from cancelling content touches. The tableview will be able to capture swipes for the delete button, while still interpreting swipes that fail the tableview's gesture requirements as page swipes. The delete button will show in cases where you hold and swipe or swipe "aggressively."

这篇关于在pageViewController内的tableView上滑动以删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆