2

i wan't to use UITableView.AllowsMultipleSelectionDuringEditing with Monotouch.Dialog. If the property is set to true, the click on the table (with edit mode enabled) seems to be ignored (no selection happens). If there is an Element.Tapped, it will be executed. In my current implementation it will push a new UIView to the NavigationController, but this is not what you expect in edit-mode.

You can reproduce the behaviour with the monotouch.dialog-sample project, just change the EditingDialog Constructor (DemoEditing.cs:57) to the following:


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

Is there a way to use AllowsMultipleSelectionDuringEditing? If yes, what's wrong with my approach?

4

1 回答 1

0

我自己的代码也遇到了同样的问题。问题是某些 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;
    }
}
于 2014-02-14T07:47:23.980 回答