简体   繁体   English

在拖放编辑模式下,UITableViewCell不会超出其行

[英]UITableViewCell won't move beyond it's row when in drag and drop edit mode

I'm following this official documentation by Apple . 我正在遵循Apple的这份官方文档 I'm trying to implement the drag and drop functionality on my UITableView . 我正在尝试在UITableView上实现拖放功能。 The problem is, that the rows won't move pass their rows. 问题是,行将无法通过它们的行。 As you can see, they always bounce back: 如您所见,它们总是反弹:

蹦蹦

Here is my code: 这是我的代码:

func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath)
{
    // This gets called, when I reach a UITableViewCell above or below
    // the one UITableViewCell I'm dragging around. This is the part
    // where it always snaps back I think.
}

func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) -> NSIndexPath
{
    return proposedDestinationIndexPath
}

I'm using the DZNEmptyDataSet library and am not quite sure, if this meddles with the original functionality of the UITableView . 我正在使用DZNEmptyDataSet库,并且不确定是否与UITableView的原始功能混为一谈

What am I missing here? 我在这里想念什么?

EDIT: I have created a new ViewController with a TableView in my project and it behaves exactly the same. 编辑:我在项目中创建了一个带有TableView的新ViewController ,它的行为完全相同。 If I try to implement this functionality in a new Project however, it simply works as intended. 但是,如果我尝试在新项目中实现此功能,则它只能按预期工作。

The 'problem' was another library MMDrawerController . “问题”是另一个库MMDrawerController When enabling editing on my TableView I have to disable the MMDrawerController gestures. TableView上启用编辑时,我必须禁用MMDrawerController手势。 Here the code the fixed my problem: 这里的代码解决了我的问题:

///
/// Enable edit mode
///
func editEntries()
{
    self.disableDrawerFunctionality()
    self.tableView.setEditing(true, animated: true)
    self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Fertig", style: .Plain, target: self, action: "finishedEditing:")
}

func finishedEditing(sender: AnyObject)
{
    self.tableView.setEditing(false, animated: true)
    self.navigationItem.rightBarButtonItem = self.barButtonItemEdit
    self.enableDrawerFunctionality()
}

// MARK: - Toggle Drawer functionalities

///
/// While in TableView edit mode: Be sure to disable the MMDrawer gestures, since the gestures will colide
/// with gestures of the TableView
///
func enableDrawerFunctionality()
{
    mm_drawerController.openDrawerGestureModeMask = .PanningCenterView
    mm_drawerController.closeDrawerGestureModeMask = .PanningDrawerView | .PanningCenterView
}

///
/// When leaving TableView edit mode: Re-enable the MMDrawer gestures after finishing editting the TableView
///
func disableDrawerFunctionality()
{
    mm_drawerController.openDrawerGestureModeMask = .None
    mm_drawerController.closeDrawerGestureModeMask = .None
}

Here the part of their readme which caught my attention: 在这里,他们的自述文件引起了我的注意:

You are free to set whatever combination you want for opening and closing. 您可以自由设置打开和关闭所需的任何组合。 Note that these gestures may impact touches sent to the child view controllers, so be sure to use these appropriately for your application. 请注意,这些手势可能会影响发送到子视图控制器的触摸,因此请确保为您的应用程序正确使用这些手势。 For example, you wouldn't want MMOpenDrawerGestureModePanningCenterView set if a MKMapView is your center view controller, since it would intercept the pan meant for moving around the map. 例如,如果MKMapView是您的中心视图控制器,则您不希望设置MMOpenDrawerGestureModePanningCenterView,因为它会拦截用于在地图上移动的平移。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM