UISearchDisplayController表视图重叠的搜索栏 [英] UISearchDisplayController table view overlapping search bar

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

问题描述

我有一个UITableViewController子类,在iPad上以模式视图显示.视图控制器具有UISearchDisplayController子类,该子类的表的标题视图中包含UISearchBar.

I have a UITableViewController subclass, displayed in a modal view on an iPad. The view controller has a UISearchDisplayController subclass with a UISearchBar included in the header view of the table.

子类UISearchDisplayController被称为NoAnimationSearchDisplayController,并且我重写了- (void)setActive:(BOOL)visible animated:(BOOL)animated 方法,以防止将搜索栏设置为活动状态时将其动画化为导航栏.方法覆盖在下面...

The subclassed UISearchDisplayController is called NoAnimationSearchDisplayController and I have overridden the - (void)setActive:(BOOL)visible animated:(BOOL)animated method to prevent the search bar from animating into the navigation bar when it's set to active. The method override is below...

- (void)setActive:(BOOL)visible animated:(BOOL)animated
{

    if (self.active == visible) {
        return;
    }

    [self.searchContentsController.navigationController setNavigationBarHidden:YES animated:NO];

    [super setActive:visible animated:animated];

    [self.searchContentsController.navigationController setNavigationBarHidden:NO animated:NO];

    if (visible) {
        [self.searchBar becomeFirstResponder];
    } else {
        [self.searchBar resignFirstResponder];
    }

}

我遇到的问题是,当我进行搜索并将结果显示在搜索显示控制器的表格视图中时,一切看起来都很好,直到我尝试向下滚动列表为止,此时出现了单元格中的内容在搜索栏上方,如以下屏幕所示:

The problem I'm having, is that when I have searched, and results are displayed in my search display controller's table view, everything looks fine untill i try to scroll down the list, at this point the content within the cells appears above the search bar, as shown in the following screen:

将搜索栏设置为UISearchBarStyleMinimal,并启用了透明性.谁能让我知道如何停止与搜索栏重叠的内容?理想情况下,内容将在搜索栏下方消失,就好像它是视图的末端一样.

The search bar is set to UISearchBarStyleMinimal and transparency is enabled. Can anyone let me know how to stop this content overlapping the search bar? Ideally the content would disappear under the search bar as if it was the end of the view.

推荐答案

请确保搜索栏未启用半透明功能(在Storyboard/xib上)或未通过代码启用. 然后将背景设置为白色或您想要的任何颜色.

Be sure the search bar is not translucent enabled ( on storyboard/xib ) or by code. Then make the background to white or whatever color you want.

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

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