Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resize UISearchDisplayController dimmed black overlay

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

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.

enter image description here

enter image description here

when clicked cancel button, the view will expend back. enter image description here

like image 592
Desmond Avatar asked Nov 03 '11 01:11

Desmond


2 Answers

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

1: override UISearchDisplayController class

@interface MySearchController : UISearchDisplayController

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: change the xib/storyboard Search Display Controller from UISearchDisplayController to MySearchController

like image 183
tomeron11 Avatar answered Nov 09 '22 04:11

tomeron11


I thought the searchDisplayController owned a seperate tableview, so my guess is that you would need to resize that one.

Something along the lines of: <yourSearchViewController>.view.frame =self.tableView.frame;

or if you don't have it as class variable, in a method which receives it as argument, eg:

-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
   controller.view.frame = self.tableView.frame;
    tableView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:236.0/255.0 blue:212.0/255.0 alpha:1];   
}

Alternativily you might want to subclass it and override its view properties locally.

Hope this helps!

like image 32
Wolfert Avatar answered Nov 09 '22 05:11

Wolfert