iphone - 调整 UISearchDisplayController 变暗的黑色覆盖层

标签 iphone ios xcode uisearchbar uisearchdisplaycontroller

有人知道如何在单击搜索栏后过度调整变暗黑色的大小吗?

我在单击取消时遇到问题,tableview 将扩展然后动画消失。

我用它来调整结果 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];   
}

当点击搜索栏时,灰色覆盖层是完整的,而不是我定义的大小。

enter image description here

enter image description here

当点击取消按钮时, View 将展开。 enter image description here

最佳答案

为了移动变暗的覆盖框架,我结合了几个答案。

1: 覆盖 UISearchDisplayController 类

@interface MySearchController : UISearchDisplayController

2:覆盖setActive函数

- (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 搜索显示 Controller 从 UISearchDisplayController 更改为 我的搜索 Controller

关于iphone - 调整 UISearchDisplayController 变暗的黑色覆盖层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7989273/

相关文章:

c++ - 从 iphone 中的固定数字集生成随机数

ios - swift + CLLocationManager : How to tell if the user is in a specific city?

ios - Xcode 5 布局错误 - 错位的 Label View Frame 在运行时会有所不同

ios - 用户是否有权访问 iOS 沙箱中的文档目录?

ios - 无法从 Facebook apprequest 检索数据

ios - 仅在 iOS < 6.0 的情况下运行代码并进行预处理?

jQuery : 2 fadeIn calls after each other not working on iPhone

iphone - 在我的对象类中使用 typedef 枚举

iphone - 有没有列出所有移动设备和规范的信息数据库?

xcode - iOS:Viewdidload 中的 NSMutableArray