MonoTouch.Dialog:在搜索上启用ScopeButton会删除搜索事件

时间:2012-07-02 21:51:52

标签: c# ios mono xamarin.ios monotouch.dialog

我不确定这是不是一个错误。

在MonoTouch.Dialog中启用ScopeButton并连接Index Change事件:

        UISearchBar sb = TableView.TableHeaderView as UISearchBar;
        sb.ScopeButtonTitles = new string[] { "Full Text".t(), "Titles".t() };
        sb.ShowsScopeBar = true;
        sb.SizeToFit();
        sb.SelectedScopeButtonIndexChanged += (sender, e) => {
            CreateRoot(sb.Text);
        };

然后过度搜索功能:

    public override void FinishSearch()
    {
        //do nothing, leave the UI 
    }

    public override void OnSearchTextChanged(string text)
    {
        CreateRoot(text);
    }

    public override void SearchButtonClicked(string text)
    {
         //Do nothing, leave the UI
    }

结果是OnSearchTextChanged永远不会触发。

如果删除后续行,它会触发并正常工作。

//Remove to re-enable SearchButtonClicked
sb.SelectedScopeButtonIndexChanged += (sender, e) => {
CreateRoot(sb.Text);
};

注意:如果您通过SubViews访问SearchBar的UISegment控件,它可以正常工作

    foreach (UIView v in sb.Subviews)
    {
        var seg = v as UISegmentedControl;
        if(seg!=null)
        {
            CreateRoot("Some text");
        };
        break;
    }

1 个答案:

答案 0 :(得分:0)

这是在最新版本的MOnotouch.dialog

中修复的