Xamarin.ios 让Scope按钮在MonoTouch UISearchBar中工作

Xamarin.ios 让Scope按钮在MonoTouch UISearchBar中工作,xamarin.ios,uisearchbar,monotouch.dialog,uisearchbardelegate,Xamarin.ios,Uisearchbar,Monotouch.dialog,Uisearchbardelegate,我已经创建了一个自定义UISearchBarDelegate。 在OnEditingStarted事件中,我将向搜索栏添加范围按钮: public override void OnEditingStarted(UISearchBar searchBar) { searchBar.ScopeButtonTitles = new[] { "Scope 1", "Scope 2" }; searchBar.ShowsCancelButton = true; searchBar.

我已经创建了一个自定义UISearchBarDelegate。 在OnEditingStarted事件中,我将向搜索栏添加范围按钮:

public override void OnEditingStarted(UISearchBar searchBar)
{
    searchBar.ScopeButtonTitles = new[] { "Scope 1", "Scope 2" };
    searchBar.ShowsCancelButton = true;
    searchBar.ShowsScopeBar = true;
}
这正按预期工作,范围按钮显示在搜索字段下方

唯一的问题是,我无法切换范围。点击“范围2”时,不会发生任何事情,甚至视觉上也不会

为了让它工作,还有其他的设置吗?
是否存在可阻止(范围)按钮工作的已知/常见陷阱?

您是否在任何地方使用
UISearchDisplayDelegate
?如果是这样,你能发布你的代码吗?有一个需要重写的
ShouldReloadForSearchScope
。不,我没有使用UISearchDisplayDelegate。我在想,即使没有连接事件或代理,按钮至少应该在点击时改变颜色。你有没有遇到过这种行为?我从来没有遇到过这种问题。快速执行
UISearchDisplayDelegate
real quick,看看它是否解决了您的问题。