调整大小UISearchDisplayController灰色黑色叠加层 [英] resize UISearchDisplayController dimmed black overlay

查看:137
本文介绍了调整大小UISearchDisplayController灰色黑色叠加层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何点击搜索栏后如何调整暗淡的黑色大小?

anybody know how to resize the dimmed black overly, once you clicked the search bar ?

我点击时遇到问题取消了tableview将耗费然后动画消失。

i having problem when i clicked cancelled the tableview will expend then animated to disappear.

我用它来调整我的结果表格视图。

i using this to resize my result tableview.

-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
   tableView.frame =fTableView.frame;//CGRectMake(26, 100, 280, 310); //fTableView.frame;
    tableView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:236.0/255.0 blue:212.0/255.0 alpha:1];   
}

点击搜索栏后,灰色叠加层已满而不是我定义的尺寸。

when clicked on the search bar, gray overlay are full instead of my defined size.

单击取消按钮时,视图将重新开始。

when clicked cancel button, the view will expend back.

推荐答案

我合并了几个答案,以便移动灰色覆盖帧。

I combined several answers in order to move the dimmed overlay frame.

1:覆盖UISearchDisplayController类

1: override UISearchDisplayController class

@interface MySearchController : UISearchDisplayController

2:覆盖setActive函数

2: override setActive function

- (void)setActive:(BOOL)visible animated:(BOOL)animated
{
[super setActive: visible animated: animated];

//move the dimming part down
for (UIView *subview in self.searchContentsController.view.subviews) {
    //NSLog(@"%@", NSStringFromClass([subview class]));
    if ([subview isKindOfClass:NSClassFromString(@"UISearchDisplayControllerContainerView")])
    {
        CGRect frame = subview.frame;
        frame.origin.y += 10;
        subview.frame = frame;
    }
}

}

3:将xib / storyboard搜索显示控制器从UISearchDisplayController更改为
MySearchController

3: change the xib/storyboard Search Display Controller from UISearchDisplayController to MySearchController

这篇关于调整大小UISearchDisplayController灰色黑色叠加层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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