How do you remove the transparent black overlay that animates over the source table view when you activate a UISearchBar?
Can you somehow get to the UIView responsible and set it's alpha to 0?
Or is there a way to display an empty searchResultsTableView on top of the black overla开发者_如何学运维y?
po [self.view subviews]
(id) $1 = 0x0a3155f0 <__NSArrayM 0xa3155f0>(
<ATShadowTableView: 0xc341600; baseClass = UITableView; frame = (0 44; 320 411); clipsToBounds = YES; gestureRecognizers = <NSArray: 0xa627200>; layer = <CALayer: 0xa626d30>; contentOffset: {0, 0}>,
<UISearchBar: 0xa618f40; frame = (0 0; 320 44); text = ''; layer = <CALayer: 0xa619040>>,
<UIControl: 0xa329fc0; frame = (0 44; 320 455); alpha = 0.8; opaque = NO; animations = { opacity=<CABasicAnimation: 0xa32b4e0>; }; layer = <CALayer: 0xa32a060>>
)
Last object (UIControl
) in self.subview is what we want to remove. So
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
...
[self performSelector:@selector(removeOverlay) withObject:nil afterDelay:.01f];
}
- (void)removeOverlay
{
[[self.view.subviews lastObject] removeFromSuperview];
}
Always have it display some cells, even if there aren't any results from the search yet. You can accomplish this through the usual UITableViewDelegate/UITableViewDataSource methods. Just be careful because you now are dealing with the original table view, the search table view, and the search table view with dummy cells in it, and all the UITableViewDelegate/UITableViewDataSource methods need to be aware of this.
精彩评论