iOS 7 UISearchDisplayController搜索栏消失 [英] iOS 7 UISearchDisplayController search bar disappears

查看:126
本文介绍了iOS 7 UISearchDisplayController搜索栏消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了我的应用并遇到了这个问题。当我开始在搜索栏中输入时,搜索栏消失,我只能看到表格视图。我仍然可以继续打字,表格视图会更新但我看不到搜索栏。
相同的设置适用于iOS< 7

I was recently updating my app and came across this issue. When i start typing in the search bar the search bar disappears and i can only see the table view. I can still keep on typing and the table view gets updated but i cannot see the search bar. Same settings works fine on iOS < 7

知道为什么会这样吗?

Any idea why this is happening ?



推荐答案

有点晚了,但我最近遇到了同样的问题。我希望搜索栏在所有搜索中都可见并处于活动状态,因此覆盖它的灰色视图是一个很大的问题。对我来说唯一有用的是改变了暗视图的框架(显然它与改变searchResultsTableView的框架不一样)。
我用以下代码设法做到了这一点:

A little late, but I've encounter the same problem just recently. I wanted the search bar to be visible and active through all of the search, so the dimmed view, which overlaid it, was a big problem. For me the only thing that worked was changing the frame of the dimmed view (apparently it's not the same as changing the frame of searchResultsTableView). I've managed to do that with the following code:

-(void)setCorrectFrames
{
    // Here we set the frame to avoid overlay
    CGRect searchDisplayerFrame = self.searchDisplayController.searchResultsTableView.superview.frame;
    searchDisplayerFrame.origin.y = CGRectGetMaxY(self.searchDisplayController.searchBar.frame);
    searchDisplayerFrame.size.height -= searchDisplayerFrame.origin.y;
    self.searchDisplayController.searchResultsTableView.superview.frame = searchDisplayerFrame;    
}

-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
    [self setCorrectFrames];
}

-(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
{
    [self setCorrectFrames];
}

这篇关于iOS 7 UISearchDisplayController搜索栏消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆