【发布时间】:2016-10-06 17:17:02
【问题描述】:
我目前正在尝试将编辑功能添加到视图控制器内的 tableView。
此视图控制器添加在作为 MapView (Mapbox) 的父 ViewController 之上。
目前,我可以使用垂直滚动上下滚动 tableView 没有任何问题。
但是,水平滑动以在 TableViewCell 上显示操作会导致 mapview 滚动其位置。
我找不到同时忽略地图视图的滚动手势。
禁用地图滚动也不能解决问题。 TableView 编辑代码:
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
//
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let test1 = UITableViewRowAction(style: .normal, title: "Test1") { (_, indexPath) in
}
test1 = UIColor=.red
let test2 = UITableViewRowAction(style: .normal, title: "Test2") { (_, indexPath) in
}
test2 = UIColor.blue
return [test1, test2]
}
以及在 Mapview 之上添加包含 TableView 的 UIViewController 的函数:
self.detailView = UIView(frame: CGRect(x: 0, y: self.view.bounds.height, width: self.view.bounds.width, height: self.view.bounds.height))
self.view.addSubview(self.detailView!)
self.detailViewController = TestViewController()
self.detailViewController!.view.frame = self.view.bounds
self.detailView?.addSubview(self.detailViewController!.view)
self.addChildViewController(self.detailViewController!)
UIView.animate(withDuration: 1.0) {
self.detailView?.frame = self.view.bounds
}
【问题讨论】:
-
我在我自己的应用程序中注意到了一个类似的问题(它把我带到了这里)。据我所知,滑动的“开始编辑”触发器非常不一致。从屏幕/表格单元的最右边缘开始滑动时,我的运气最好。我查看了 raywenderlich 关于滑动表格单元格的文章,但他们声称 UITableViewRowAction 已弃用它,您和我都同意它的默认形式是不够的。祝你好运找到更好的解决方案!
标签: ios swift uitableview mapbox