我有一个基于tabbar的应用程序,并且UInavigationcontroller
为每个选项卡。在TabViewController
中,我实现了UIsegmentedcontrol
,searchDisplayController
和uitableview。 navigationItems,tabledata根据分段控制选择进行更改。对于我隐藏搜索栏的细分受众群。但是,当搜索栏被隐藏时,tableview第一行不响应didselectrowatindexpath
。隐藏UISearchDisplayController的UISearchBar
这里是我的代码,
在段变化的行动
- (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];
}
其他代码是通用的,其他的事情正在正确的。
第二个问题是,当我通过单击某一行从细节视图返回时,表格框架的更改未保留。搜索栏有一个空间。
等待帮助。
谢谢你的时间,但我的代码完全隐藏了搜索栏。我在其他地方遇到问题。第一次单击不响应表格单元格,当tableview返回时,它不会在搜索栏隐藏后保留更改的框架。 – tausun
哦,我看到你的答案:)这样的事情总是发生在我身上:D,我很高兴你明白了,并感谢upvote :) – Yanchi
不是一个不好的解决方案。我对“显示”代码中44个硬编码假设有点谨慎。但是,“隐藏”代码在iOS 7中工作得很好。 – Mark