标签: uisearchdisplaycontroller

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

隐藏UITableView搜索栏

我有一个UITableViewController以标准方式设置UISearchDisplayController(在tableView中有搜索栏).我希望搜索栏开始隐藏 - 真正隐藏,而不仅仅是在此解决方案中滚动.然后,当用户按下按钮时,我想呈现搜索UI,并在用户选择搜索中找到的项目之后再次隐藏它(真正隐藏它).

这是几乎可以工作的代码:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.searchDisplayController.searchBar.prompt = @"Add an item";
    self.searchDisplayController.searchBar.placeholder = @"Type the item name";

    // i do this to trigger the formatting logic below
    [self.searchDisplayController setActive:YES animated:NO];
    [self.searchDisplayController setActive:NO animated:NO];
    // rest of my view will appear
}

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {

    NSTimeInterval duration = (self.isViewLoaded && self.view.window)? 0.3 : 0.0;
    __block CGFloat searchBarHeight = controller.searchBar.frame.size.height;

    [UIView animateWithDuration:duration animations:^{
        self.tableView.contentOffset = CGPointMake(0, searchBarHeight);
        self.tableView.contentInset = UIEdgeInsetsMake(-searchBarHeight, 0, 0, 0);  // trouble here, …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview uisearchbar uisearchdisplaycontroller ios

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

一旦在搜索显示控制器中选择了表视图单元格,如何隐藏searchresultstableview?

我正在研究searchdisplaycontroller.一旦在表视图中选择了特定单元格,如何隐藏searchresults表视图.

iphone objective-c uisearchdisplaycontroller

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

如何在UISearchDisplayController中将默认文本更改为"无结果"

我有一个UISearchBar和一个UISearchBarDisplayController由xib设置.在没有结果的搜索之后,它在表格中显示"无结果".如何修改默认文字?

iphone xcode uisearchbar uisearchdisplaycontroller

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

UISearchBar搜索两个数组

我有一个搜索数组的搜索栏,并用结果更新UITableView.表格视图是书籍列表,包括标题和作者:

标题和作者

现在,搜索栏只搜索标题,但我想让它搜索作者.这是我的搜索代码(我从http://blog.webscale.co.in/?p=228获得).

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    [tableData removeAllObjects];// remove all data that belongs to previous search
    if([searchText isEqualToString:@""]||searchText==nil){
        [tableView reloadData];
        return;
    }

    for(NSString *name in dataSource){
         NSInteger counter = 0;

        //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
        NSRange r = [[name lowercaseString] rangeOfString:[searchText lowercaseString]];
        if(r.location != NSNotFound)
            [tableData addObject:name];


            counter++;
    }
        //[pool release];


    [tableView reloadData];
Run Code Online (Sandbox Code Playgroud)

}

dataSource是包含标题的NSMutable Array.包含作者的数组称为"作者"."tableData"是存储应该出现在屏幕上的单元格的数组(包含要搜索的术语的单元格).

非常感谢,

卢克

xcode objective-c uisearchbar uisearchdisplaycontroller ios

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

UISearchDisplayController中的searchResultsTitle不起作用

我想自定义"无结果"字符串UISearchDisplayController.在文档中,您可以找到UISearchDisplayController具有searchResultsTitle我认为应该更改此字符串的属性,但它不起作用.
请帮助在iOS 5及更高版本中自定义"无结果"字符串.为什么searchResultsTitle不起作用?

uitableview nsstring uiviewcontroller uisearchbar uisearchdisplaycontroller

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

UISearchDisplayController动画reloadData

我一直在阅读有关UISearchDisplayController它的所有文档,delegate但是当搜索条件发生变化时,我找不到任何方法来动画表格视图.

我正在使用这两种方法: UISearchDisplayController方法

他们都返回,YES但仍然找不到任何方法做类似的事情: UITableView方法

我不知道这是否是重要的,但我使用的是NSfetchedResultsController 填充UITableViewUISearchDisplayController

那是谢谢!

core-data uitableview uisearchdisplaycontroller nsfetchedresultscontroller

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

如何在按下搜索按钮后才能使UISearchDisplayController进行搜索

我正在我的iOS应用程序中实现搜索,到目前为止,我正在使用shouldReloadTableForSearchString方法从搜索栏中获取字符串以执行搜索.但是我注意到只要用户输入的字符串发生更改,该方法就会调用.搜索一个人的联系人很好,但这不是我正在使用它的所以我正在寻找一种方法,只有在用户点击搜索时才开始搜索并输入他们的字符串而不是他们的输入.我该怎么做呢?

uisearchdisplaycontroller ios

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

自定义单元格无法在UITableView中搜索结果

首先,我想告诉我,我已经研究并尝试遵循诸如UISearchDisplayController和自定义单元格之类的stackoverflow链接,但问题仍然存在

我将搜索栏和搜索显示控制器集成到我的UITableView中.搜索功能正常但搜索结果单元格具有默认的白色单元格设计,而不是用于UITableView的自定义单元格设计.下面是我的代码,使搜索结果的Cell设计适应我的自定义设计.

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.searchDisplayController.searchResultsTableView registerClass:[ItemCellTableViewCell class] forCellReuseIdentifier:@"Cell"];
    if(!self.document){
        [self initDocument];
    }
    self.filteredItemCatalogArray = [[NSMutableArray alloc]init];
    self.itemCatalogTableView.dataSource = self;
    self.itemCatalogTableView.delegate = self;
    [self.itemCatalogTableView reloadData];
    self.itemCatalogTableView.backgroundColor = [UIColor clearColor];
    self.itemCatalogTableView.opaque = NO;
    self.itemCatalogTableView.bounces = YES;
    self.itemCatalogTableView.backgroundView = nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    if(tableView == self.searchDisplayController.searchResultsTableView)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        //cell fields customization
        cell.backgroundColor = [UIColor clearColor];
        cell.opaque = NO;
        return cell;
    }
    else
    {
        ItemCellTableViewCell …
Run Code Online (Sandbox Code Playgroud)

uitableview uisearchbar uisearchdisplaycontroller ios

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

使用Parse查询在Swift中调用REST API

我正在尝试在我使用内置REST API创建的Parse数据库上发出GET请求.当用户在UISearchBar中输入文本时,将进行API调用,最终目标是在UITableView中显示返回的数据.下面的代码仅捕获我尝试发出有效的HTTP请求,我试图查看"Query1"是否与搜索字符串匹配("Query1"是我的Parse数据库中的一个参数,基本上用作关联的搜索词).

//Mark - UISearchBarDelegate

func searchBarSearchButtonClicked(searchBar: UISearchBar) {
    makeRequest(searchBar.text)
}

func makeRequest (searchString : String) {

    //REST API call to the sampleObjectData class
    var request = NSMutableURLRequest(URL: NSURL(string: "https://api.parse.com/1/classes/sampleObjectData")!)
    let session = NSURLSession.sharedSession()
    request.HTTPMethod = "GET"

    //THIS IS MY TROUBLE AREA
    var params = urllib.urlencode({"where";:json.dumps({
        "Query1": "\(searchString)"
        })})

    var error: NSError?

    request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &error)
    request.addValue("application/json", forHTTPHeaderField: "Content-Type")
    //The kAppId & kRestAPIKey calls are referencing contstants at the top of the file
    request.addValue("X-Parse-Application-Id", forHTTPHeaderField: …
Run Code Online (Sandbox Code Playgroud)

rest uisearchdisplaycontroller ios parse-platform swift

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