When a user has tapped in a search bar, hasn't entered any text, and the screen has been darkened (but the tableview has not appeared yet), I would开发者_运维问答 like to put a button on the screen to allow the user to navigate away to some other functionality. Is that possible?
Thanks!
This is quite tricky. The _dimmingView is private to the searchDisplayController and it goes above all subviews. What you can do is cover it with your custom view every time it appears ([searchString length] == 0 and DidBeginSearch)
(tempView's frame is set for UISearchBar placed on table's tableViewHeader)
- (void)viewDidLoad {
    tempView = [[UIView alloc] initWith...];
    // tempView setup
    ...
}
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
    [tempView setFrame:CGRectMake(0, self.searchDisplayController.searchBar.frame.size.height, 320, self.searchDisplayController.searchResultsTableView.frame.size.height)];
    [self.searchDisplayController.searchContentsController.view addSubview:tempView];
    ...
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    if ([searchString length] == 0) 
         [self.searchDisplayController.searchContentsController.view addSubview:tempView];
    else 
         [tempView removeFromSuperview];
    ...
}
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
    if (tempView && tempView.superview) 
        [tempView removeFromSuperview];
    ...
}
Notes: I tried creating a new instance on DidBeginSearch and releasing it on DidEndSearch, and it worked only for the 1st call! Weird...
Hope this helps
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论