【问题标题】:UISearchBar- change scope without greying out table?UISearchBar-更改范围而不使表格变灰?
【发布时间】:2010-03-13 19:08:14
【问题描述】:

如何在不让表格变灰、搜索字段变为第一响应者和键盘弹出窗口的情况下允许更改范围?

我只是想根据范围刷新显示的数据。

【问题讨论】:

  • 是什么触发了范围的变化? (用户输入等)

标签: iphone scope uisearchbar uisearchdisplaycontroller first-responder


【解决方案1】:

我通过以下方式实现了这一点:

@interface SearchViewController : UIViewController<UISearchBarDelegate, UISearchDisplayDelegate> {
    BOOL shouldBeginEditing;
}

@end  

@implementation SearchViewController

-(void)searchBar:(UISearchBar *)bar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope
{
    shouldBeginEditing = NO;
}

-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)bar
{   
    if (shouldBeginEditing)
    {
        return YES;
    }
    else
    {
        shouldBeginEditing = YES;
        return NO;
    }
}

@end

【讨论】:

    【解决方案2】:

    如果您使用标准 UISearchBar 范围按钮更改范围,则覆盖 UISearchDisplayDelegate 中的 searchDisplayController:shouldReloadTableForSearchScope 方法并让它执行您需要的任何操作。

    【讨论】:

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