[英]Pass delete swipe gesture from UIPageViewController to UITableView
I have a UITableView
inside a UIPageViewController
and swipe events don't seem to be passing to the UITableView
. 我在UIPageViewController
有一个UITableView
并且滑动事件似乎没有传递给UITableView
。
I was able to disable bouncing of edges for my UIPageViewController
, but I still haven't found a way to consistently enable swiping to delete in my UITableView
. 我能够为UIPageViewController
禁用边缘UIPageViewController
,但仍然没有找到在UITableView
始终启用滑动删除功能的方法。
In this sample, it takes multiple swipes to get the delete button to show up. 在此示例中,需要多次滑动才能显示删除按钮。 The gesture is extremely finicky on an actual device 在实际设备上的手势极其挑剔
There isn't another page after the page on the right, so there's no reason for the UIPageViewController
to need that swipe. 右侧页面后没有其他页面,因此没有必要让UIPageViewController
进行滑动。
In viewDidLoad
I have: 在viewDidLoad
我有:
for view in self.pageViewController.view.subviews {
if let scrollView = view as? UIScrollView {
scrollView.delegate = self
}
}
Below that I have: 下面我有:
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
print(gestureRecognizer)
if gestureRecognizer is UISwipeGestureRecognizer {
return false
}else{
return true
}
}
There are a lot of related posts with different answers, but none of them work for my use case. 有很多相关的文章有不同的答案,但是没有一个适合我的用例。
您可以通过不使用datasource
来禁用UIPageViewController的滑动,只需使用setViewControllers:direction:animated:completion
方法提供内容即可。希望tableView的滑动可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.