标签: uisearchdisplaycontroller

在调用cancelButton之后,将UISearchBar隐藏在UINavigationBar下面

我通常使用[self.tableView setContentOffset:CGPointMake(0,40)];以隐藏在navigationBar下面的UISearchBar(我将其设置为tableView的标题).在viewDidLoad中一切正常:加载视图时,searchBar位于navigationBar下方.然后我把相同的代码行

[self.tableView setContentOffset:CGPointMake(0,40)]
Run Code Online (Sandbox Code Playgroud)

- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
Run Code Online (Sandbox Code Playgroud)

但它可以做任何事情:单击取消按钮时,searchBar仍然可见.怎么了?

iphone cancel-button uisearchbar uisearchdisplaycontroller

5
推荐指数
1
解决办法
4838
查看次数

首次使用前UISearchBar尺寸不一致?

由于一个不清楚的原因,我的UISearchBar在第一次搜索后将其自身调整为不同的大小.这个搜索栏没有什么特别之处.它基于Apple IOS库上的示例,并使用searchDisplayController,几乎没有自定义.

之前:

在搜索之前

后:

搜索后

当视图加载时,如何将大小设置为第二个屏幕截图中的大小?

iphone uisearchbar uisearchdisplaycontroller ios4 ios5

5
推荐指数
1
解决办法
145
查看次数

在用户开始在SearchBar中输入之前,有没有办法在结果中预先填充UISearchDisplayController?

我想在搜索栏变为活动状态后立即显示过去的搜索.但即使数据源具有这些值,搜索显示控制器也不会调用表视图方法,直到用户开始键入.有没有办法在UISearchDisplayController上强制执行此操作?

iphone objective-c uisearchbar uisearchdisplaycontroller

5
推荐指数
1
解决办法
271
查看次数

当我点击它时,UISearchBar会进入视图的顶部

我有一个UITableView,它无法到达整个视图.近似地,UITableView比视图小两倍.

然后,我将"搜索栏和搜索显示控制器"添加对象库中的UITableView .因此,为了可视化,searchBar出现在屏幕的中心.

这是我的观点:

在此输入图像描述

我的问题:当我点击搜索字段进行我的研究时,searchBar将转到视图的顶部,代替导航栏!过渡非常糟糕......我如何限制searchBar保持在最初的位置?

iphone uisearchbar uisearchdisplaycontroller ios

5
推荐指数
1
解决办法
3141
查看次数

UISearchBar到UISearchDisplayController的转换是20px

我正在UITableView的顶部实现一个UISearchBar.

在我设置的ViewDidLoad中self.edgesForExtendedLayout = UIRectEdgeNone.

这是我如何添加我的UISearchBar.我只是将UISearchBar添加到我的UITableView的标题并调整内容偏移量:

// Table View
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.screenWidth, self.screenHeight)];

self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

// Customize table appearance
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
self.tableView.backgroundColor = [UIColor tableBackgroundColor];

// Define the table's datasource
self.tableView.dataSource = self;
self.tableView.delegate = self;

[self.view addSubview:self.tableView];


// Add a search bar to the header
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.screenWidth, 44)];
self.searchBar.tintColor = [UIColor primaryBrandedColor];
self.searchBar.placeholder = NSLocalizedString(@"Search", "Search placeholder");
self.searchBar.backgroundImage = [UIImage imageNamed:@"searchBarBackground"];
[self.searchBar setBackgroundImage:[UIImage imageNamed:@"searchBarBackground"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uisearchbar uisearchdisplaycontroller ios

5
推荐指数
1
解决办法
2888
查看次数

带有搜索显示控制器的刷新控件出现在搜索栏上方

我已经实现了一个简单的 Table View Controller,其中一个 Search Display Controller 通过 Interface Builder 拖出。然后我启用了刷新,以便在用户下拉刷新时可以看到刷新控件。

问题是,当它应该位于搜索栏下方时,微调器在搜索栏顶部可见。

我知道原因是最小搜索样式。如果您使用默认的 Prominent 样式,则问题不存在。

当您慢慢下拉时,您会看到第一行出现在搜索栏上方,如下所示: 在此处输入图片说明

如果您继续拉动它确实会出现在您期望的位置,但是如果您在视图仍在刷新时将其推回原位,您将在搜索栏顶部看到微调器,如下所示: 在此处输入图片说明

只要向上推它使微调器接触第一节标题,微调器立即消失。

这就是它的外观,就像在邮件中一样 - 在搜索栏下方: 在此处输入图片说明

我试图通过简单地将微调器放在搜索栏下方来解决这个问题,这样它就不会出现在顶部,但这不起作用。奇怪的是,该代码导致微调器在表格上方的灰色区域中不可见,如果您将其向上推,它会出现在搜索栏上方 - 与我所期望的完全相反。这是代码:

self.refreshControl.layer.zPosition = self.searchDisplayController.searchBar.layer.zPosition - 1;
Run Code Online (Sandbox Code Playgroud)

使用最小样式时,如何防止微调器出现在搜索栏顶部?

objective-c uitableview uisearchdisplaycontroller ios uirefreshcontrol

5
推荐指数
1
解决办法
1611
查看次数

点击按钮后显示 UISearchController

我正在寻找一种方法,如何在点击按钮后显示带有搜索栏的搜索视图。我是否想创建一个带有搜索栏的新 UIView,然后在点击按钮后转到该 UIView?或者有更好的选择吗?

您可以将其想象为在 Youtube 应用程序中搜索,但您会在键入时看到搜索结果。

编辑: 所以现在我设法在点击按钮后显示搜索栏,但它没有正确显示。问题是当搜索栏向下移动时,它被从下切下来:

点击按钮后:

打字:

点击取消按钮:

我的代码:

implementation ViewController {
  NSInteger listNo;
  DataClass *dataClass;
  UITableViewController *searchResultsController;
}


- (void)viewDidLoad {
  [super viewDidLoad];
  dataClass = [DataClass getInstance];
  self.navigationController.navigationBarHidden = YES;


  // Prepare Search Controller and Result Controller
  searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
  searchResultsController.tableView.dataSource = self;
  searchResultsController.tableView.delegate = self;

  self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
  self.searchController.searchResultsUpdater = self;
  self.searchController.delegate = self;
  self.searchController.searchBar.delegate = self;
  self.searchController.searchBar.frame =   CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y + 5,  self.searchController.searchBar.frame.size.width, 44.0);
  [self.searchController.searchBar sizeToFit];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 5; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiview uisearchbar uisearchdisplaycontroller ios

5
推荐指数
0
解决办法
1513
查看次数

搜索栏在变为活动状态时被导航栏隐藏

我面临一个奇怪的场景,我在我的应用程序中使用了一个搜索栏,并将其与表视图绑定,如下图所示!

在此输入图像描述

但是,当我尝试搜索任何搜索栏向上滑动并被导航栏隐藏时,我已经多次使用搜索栏,从未见过我这样的事情就是它的屏幕截图!

在此输入图像描述

我不能删除导航栏,因为我需要它,但我无法弄清楚为什么或如何发生,

需要注意的一点是,搜索栏和它的控制器在尝试搜索时工作正常,只是它被隐藏在导航栏后面,

任何有关这方面的帮助将不胜感激,因为我无法弄清楚它的原因.

uinavigationbar uisearchbar uisearchdisplaycontroller ios

5
推荐指数
1
解决办法
2484
查看次数

搜索显示控制器在iOS8中已弃用

我在尝试运行代码时收到上述警告消息.

NSDictionary *tempDictionary = nil;

    if (self.tableView == self.searchDisplayController.searchResultsTableView) {
        tempDictionary = [filteredCompanyArray objectAtIndex:indexPath.row];
    }
    else {
        tempDictionary= [self.client_list objectAtIndex:indexPath.row];
    }
Run Code Online (Sandbox Code Playgroud)

它已被弃用并进行谷歌搜索,但我看到的只是Swift的教程.

我在这里按照Ray Wenderlich教程http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view但现在我卡住了.

#pragma mark Content Filtering
-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
    // Update the filtered array based on the search text and scope.
    // Remove all objects from the filtered search array
    [self.filteredCompanyArray removeAllObjects];
    // Filter the array using NSPredicate
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.name contains[c] %@",searchText];
    filteredCompanyArray = [NSMutableArray arrayWithArray:[self.client_list filteredArrayUsingPredicate:predicate]];
}

#pragma mark - UISearchDisplayController Delegate …
Run Code Online (Sandbox Code Playgroud)

objective-c uisearchdisplaycontroller ios

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

搜索方法迭代完成后重新加载/显示UISearchDisplayController的searchResultsTableView

我修改了Apple的示例iOS项目TableSearch的代码,以便通过解析其内容来使用它来搜索Web服务.我使用SearchDisplayController的SearchBar执行搜索时,除了一个丑陋的细节之外,我所实现的一切都很好.我已经改变了SearchDisplayController的行为,以便在点击"搜索"按钮时首先调用我的搜索功能.

问题是当搜索迭代(在NSOperationQueue的后台执行)完成时,(searchDisultsTableView)(searchDisplayController)不会自动显示或未分配结果内容.如果您随后更改SearchBar的文本或点击触摸搜索字段时出现的视图中的"取消"按钮(请参阅TableSearch),则会显示正确的TableView以及搜索结果.我只是希望在搜索操作完成后立即执行此步骤,因此在您进行交互之前.在此阶段,当前显示"无结果"标签.方法"filterContentForSearchText"和"shouldReloadTableForSearchString"与原始TableSearch项目相同.

我已经看了SearchDisplayController及其属性的不同类引用,但我还没有找到任何最终解决方案.

我已经在NSOperation完成后明确迭代的部分中尝试了以下内容,但它似乎没有解决问题.

[self.searchDisplayController.searchResultsTableView removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)

self.searchDisplayController.searchResultsTableView.hidden = YES;
Run Code Online (Sandbox Code Playgroud)

这些操作都具有我想要显示的正确视图但是滚动被禁用,直到您更改状态以便再次隐藏视图.但是,可以选择TableView单元格.我基本上想要只启用滚动功能...

在此先感谢您的努力!

iphone cocoa-touch objective-c uisearchdisplaycontroller

4
推荐指数
1
解决办法
8699
查看次数