标签: searchdisplaycontroller

UISearchDisplayController没有结果tableView?

通常,UISearchDisplayController在激活时会使tableView变暗并聚焦searchBar.只要在searchBar中输入文本,它就会创建一个searchResultsTableView,它在searchBar和键盘之间显示.当第二个UITableView被加载/显示/隐藏/卸载时,将调用searchDisplayController的委托.通常它会在输入时显示实时搜索结果或自动完成条目.

在我的应用程序中,我想搜索Web服务,我不想为用户输入的每个字母调用webservice.因此,我想完全禁用searchResultsTableView并在输入文本时保持暗灰色覆盖.然后,一旦他点击搜索按钮,我就会触发搜索(带有加载屏幕).

只返回searchResultsTableView的零行看起来不太好,因为它显示一个带有"无结果"消息的空searchResultsTableView.我试图在它出现时隐藏表(searchDisplayController:didLoadSearchResultsTableView:),但是黑色的灰色叠加层也是隐藏的,这样底层的tableView再次完全可见.

除了从头开始重新创建UISearchDisplayController功能之外的任何想法?

iphone objective-c uisearchbar searchdisplaycontroller

42
推荐指数
4
解决办法
3万
查看次数

searchDisplayController:更改标签"No Results"

使用searchDisplayController时如何更改标签"No Results"?

问候

iphone cocoa-touch uikit searchdisplaycontroller

7
推荐指数
2
解决办法
5609
查看次数

正确实例化UISearchDisplayController

我做了一些搜索,答案仍然不清楚.我试图在TableViewController(TVC)中创建一个UISearchDisplayController的实例.

在我的TVC的标题中,我将searchDisplayController声明为属性:

@interface SDCSecondTableViewController : UITableViewController

@property (nonatomic, strong) NSArray *productList;
@property (nonatomic, strong) NSMutableArray *filteredProductList;
@property (nonatomic, strong) UISearchDisplayController *searchDisplayController;

@end
Run Code Online (Sandbox Code Playgroud)

这样做会产生错误:

属性'searchDisplayController'试图使用超类'UIViewController'中声明的实例变量'_searchDisplayController'

添加@synthesize searchDisplayController实现文件摆脱了错误.

任何人都可以帮我理解这个错误吗?我正在使用Xcode 4.6.2,但我认为属性是从Xcode 4.4开始自动合成的.

properties searchdisplaycontroller ios xcode4.6

3
推荐指数
1
解决办法
1827
查看次数

如何使用Storyboard Dynamic Prototypes TableViewCell格式化SearchDisplayController结果

我创建了TableViewController子类并将其与故事板一起使用.我创建了1个动态原型并在子类中使用了它的Identifier值.它工作并显示故事板中显示的单元格.但是当我添加searchDisplayController并使TableViewController成为委托和数据源时,它会显示corrct搜索结果,但TableViewCells的格式不再遵循storyboard原型.我在下面使用的代码.我怎样才能让它跟随原型?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Contact Cell";
    static NSString *sCellID = @"Contact Cell";
    UITableViewCell *cell;
        if (tableView == self.searchDisplayController.searchResultsTableView) {
            cell = [tableView dequeueReusableCellWithIdentifier:sCellID];
            if (cell == nil) 
            {            
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:sCellID];
            }
        }
        else
        {
            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) 
            {            
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
        }


    // ask NSFetchedResultsController for the NSMO at the row in question
    Contact *contact = [self.fetchedResultsController objectAtIndexPath:indexPath];
    // …
Run Code Online (Sandbox Code Playgroud)

objective-c storyboard searchdisplaycontroller ios

2
推荐指数
1
解决办法
2534
查看次数

调整SearchResultsTableView的大小

我正在ViewController中实现SearchDisplayController.除了一件事之外,它正在运行:我控制searchResultTableView属性来调整tableView的大小,其中显示结果,此控件在saarchBar的textDidChange方法中完成.

但是当我键入第一个字符时,tableView没有调整大小,只有当我键入第二个字符时才会调整大小.这是我的代码:

- (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    CGRect tableFrame= self.searchDisplayController.searchResultsTableView.frame;
    tableFrame.size.height=400;
    tableFrame.size.width=300;
    [self.searchDisplayController.searchResultsTableView setFrame:tableFrame];
    [self.searchDisplayController.searchResultsTableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)

我还尝试在searchDisplayControllerDidBeginSearch,didLoadSearchResultTableView或viewDidLoad方法中调整tableView的大小,但它没有用.

我究竟做错了什么?

uitableview searchdisplaycontroller ios

2
推荐指数
1
解决办法
2102
查看次数