【问题标题】:AllowsMultipleSelectionDuringEditing not supported by Monotouch.Dialog?Monotouch.Dialog 不支持 AllowsMultipleSelectionDuringEditing?
【发布时间】:2012-09-26 13:17:59
【问题描述】:

我不想将 UITableView.AllowsMultipleSelectionDuringEditing 与 Monotouch.Dialog 一起使用。如果该属性设置为 true,则似乎会忽略对表的单击(启用编辑模式)(不进行选择)。如果有一个 Element.Tapped,它将被执行。在我当前的实现中,它会将新的 UIView 推送到 NavigationController,但这不是您在 edit-mode 中所期望的。

您可以使用 monotouch.dialog-sample 项目重现该行为,只需将 EditingDialog 构造函数 (DemoEditing.cs:57) 更改为以下内容:


    public EditingDialog (RootElement root, bool pushing) : base (root, pushing)
    {
      TableView.AllowsMultipleSelectionDuringEditing = true;
    }

有没有办法使用 AllowsMultipleSelectionDuringEditing?如果是,我的方法有什么问题?

【问题讨论】:

  • 你能最终解决这个问题吗?我已经对此感到困惑了一段时间......
  • 对不起,我没认出你的评论。你还有兴趣吗?我做了一个解决方法,但我必须先从我的存储库中获取它。
  • 不用担心虚幻!我已经完全忘记了它,我想我也想出了一个解决方法......

标签: xamarin.ios monotouch.dialog


【解决方案1】:

我自己的代码也遇到了同样的问题。问题是某些 MonoTouch.Dialog 元素的单元格 SelectionStyle 设置为 UITableViewCellSelectionStyle.None。

我通过子类 Source 或 SizingSource 解决了这个问题:

public class MyTableViewSource : Source
{
    public MyTableViewSource(DialogViewController container) : base(container)
    {
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        var cell = base.GetCell(tableView, indexPath);
        cell.SelectionStyle = UITableViewCellSelectionStyle.Gray; // something other than None
        return cell;
    }
}

然后在你的 DialogViewController 中:

public class MyDialogController : DialogViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        // setup root element
        Root = new RootElement();

        // . . .

        TableView.Source = new MyTableViewSource(this);
        TableView.AllowsMultipleSelectionDuringEditing = true;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多