mardi 5 juillet 2016

How to dismiss UISearchBar when seguing?

I created a simple project to simulate what issue is occurring.

Here is the project that replicates the issue: http://www.filedropper.com/uisearchcontroller-demo-master2

To create the issue, simply segue after typing and then tapping on a cell to segue, you will notice that the UISearchBar stays on top versus without searching it dismisses.

heres how im creating it in the initial tableView

UINavigationController *searchResultsController = [[self storyboard] instantiateViewControllerWithIdentifier:@"TableSearchResultsNavController"];

    // Our instance of UISearchController will use searchResults
    self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];

    // The searchcontroller's searchResultsUpdater property will contain our tableView.
    self.searchController.searchResultsUpdater = self;

    // The searchBar contained in XCode's storyboard is a leftover from UISearchDisplayController.
    // Don't use this. Instead, we'll create the searchBar programatically.
    self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x,
                                                       self.searchController.searchBar.frame.origin.y,
                                                       self.searchController.searchBar.frame.size.width, 44.0);

    self.searchController.searchBar.tintColor = [UIColor blackColor];

    self.tableView.tableHeaderView = self.searchController.searchBar;

Aucun commentaire:

Enregistrer un commentaire