ISearchDisplayController的UISearc

ISearchDisplayController的UISearc

本文介绍了隐藏UISearchDisplayController的UISearchBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于tabbar的应用程序,每个选项卡都有 UInavigationcontroller 。在 TabViewController 中,我实现了 UIsegmentedcontrol searchDisplayController 和uitableview。 navigationItems,tabledata基于segmentedcontrol选择进行更改。对于一个片段,我隐藏了搜索栏。但是当隐藏搜索栏时,tableview第一行不响应 didselectrowatindexpath

I have a tabbar based application, and UInavigationcontroller for every tab. In a TabViewController, I have implemented a UIsegmentedcontrol, searchDisplayController and uitableview. The navigationItems, tabledata are changed based on the segmentedcontrol select. And for a segment i have hidden the search bar. But when the searchbar is hidden, tableview first row does not respond to didselectrowatindexpath.

这是我的代码,

在细分更改操作中

- (void)indexDidChangeForSegmentedControl:(UISegmentedControl *)aSegmentedControl {
[self changeNavigationItems];

l.text = [NSString stringWithFormat:@"%d",self.segmentControl.selectedSegmentIndex];
if([segmentIndexesToHideSearchBar containsObject: [NSString stringWithFormat:@"%d", self.segmentControl.selectedSegmentIndex]])
{
    self.searchDisplayController.searchBar.hidden = YES;
    self.dataTable.frame = CGRectMake(0, 0, self.dataTable.frame.size.width, self.dataTable.frame.size.height);
}
else
{
    self.searchDisplayController.searchBar.hidden = NO;
    self.dataTable.frame = CGRectMake(0, 44, self.dataTable.frame.size.width, self.dataTable.frame.size.height);
}
[self.dataTable reloadData];

}

其他代码是通用的,其他的工作正常。

Other codes are generic and other things are working correct.

第二个问题是,当我通过点击一行从详细信息视图返回时,不保留表格框架的更改。搜索栏有一个空格。

Second problem is when i am getting back from a details view by clicking on a row, the change of frame of table is not kept. There is a space where searchbar was.

等待帮助。

推荐答案

didSelectRowAtIndexPath for didDeselectRowAtIndexPath 。这是一个多么愚蠢的错误,我忍受了几个小时...... :(

I have figured that out. My first problem was the first click on tableview row did not respond. That was for i have mistaken didSelectRowAtIndexPath for didDeselectRowAtIndexPath. What a silly mistake and I suffered for hours...:(

第二个问题是因为我在中编写了隐藏和帧更改代码viewDidLoad 函数,我将代码移动到 viewDidAppear 函数。现在代码工作正常。

The second problem was for I was writing the hiding and frame changing code in viewDidLoad function, I moved the code to viewDidAppear function. Now the codes are working properly.

这篇关于隐藏UISearchDisplayController的UISearchBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 14:54