iPhone SDK: Setting the size of UISearchDisplayController's table view

前端 未结 3 845
天命终不由人
天命终不由人 2020-12-14 21:20

My app\'s table view does not occupy the full screen height, as I\'ve allowed 50px at the bottom for a banner.

When I begin typing in the search bar, the search resu

3条回答
  •  独厮守ぢ
    2020-12-14 22:01

    I updated the code to allow for deeper view hierarchies, but the initial frame of the semi-transparent cover view still takes up the entire window below the search bar.

    -(void)searchDisplayController: (UISearchDisplayController*)controller 
     didShowSearchResultsTableView: (UITableView*)tableView 
    {
        if ( [controller.searchBar.superview isKindOfClass: [UITableView class]] )
        {
            UITableView* staticTableView = (UITableView*)controller.searchBar.superview;
    
            CGRect f = [tableView.superview convertRect: staticTableView.frame fromView: staticTableView.superview];
            CGRect s = controller.searchBar.frame;
            CGRect newFrame = CGRectMake(f.origin.x,
                                         f.origin.y + s.size.height,
                                         f.size.width,
                                         f.size.height - s.size.height);
    
            tableView.frame = newFrame;
        }
    }
    

提交回复
热议问题