Monotouch“滑动删除"CommitEditingStyle 未触发 [英] Monotouch "Swipe To Delete" CommitEditingStyle Not Firing

查看:32
本文介绍了Monotouch“滑动删除"CommitEditingStyle 未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 uitableview 中实现滑动删除"功能.我遵循了其他教程/论坛并扩展了 UITableViewSource.在该类中,我覆盖了以下方法:

I am trying to implement "swipe to delete" functionality in a uitableview. I have followed other tutorials/forums and extended UITableViewSource. Within that class I have overridden the following methods:

public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
   if (editingStyle == UITableViewCellEditingStyle.Delete)
   {
       tableItems.RemoveAt(indexPath.Row);
       tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Fade);
   }
}

public override UITableViewCellEditingStyle EditingStyleForRow(UITableView tableView, NSIndexPath indexPath)
{
    return UITableViewCellEditingStyle.Delete;
}

public override bool CanEditRow(UITableView tableView, NSIndexPath indexPath)
{
    return true;
}

我相信这些是我唯一需要的方法.但是,当我执行滑动手势时,会调用 CanEditRow 和 EditingStyleForRow 方法,但从未调用 CommitEditingStyle.任何帮助将非常感激.谢谢.

I believe these are the only methods I should need. However when I perform a swipe gesture, the CanEditRow and EditingStyleForRow methods are called but CommitEditingStyle is never called. Any help would be much appreciated. Thanks.

推荐答案

我正在回答我自己的问题.事实证明我的列表视图比它的容器大,所以删除按钮只是隐藏在屏幕外.脸掌.

I'm answering my own question. It turns out my listview was larger than its container so the delete buttons were simply hidden offscreen. Face palm.

sblom 关于哪些事件被触发的知识对我有很大帮助.好资料.

sblom's knowledge about which events get fired when helped me a lot. Good info.

这篇关于Monotouch“滑动删除"CommitEditingStyle 未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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