It appears that the UISearchController forgets to reset the searchBar frame when the status bar appears. I think this is probably a bug in the UISearchController ; it seems some of them are listed in radar . It seems that the searchBar superview (which is internal to the UISearchController) ends up with the wrong height. This is frustrating, because the solution therefore includes getting into the hierarchy of searchController views that Apple can change ... you can add iOS version checking so that it runs only for specific versions.
If you add the code below to your view controller, it will be called when the collection of features changes. It verifies that: a) the active search controller, b) the status of the Bar is not hidden, and c) the source of searchBar-y is 0, and if so, it increases the surveillance height by the height of the statusBar that the searchBar moves.
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) { let app = UIApplication.sharedApplication() if searchController!.active && !app.statusBarHidden && searchController?.searchBar.frame.origin.y == 0 { if let container = self.searchController?.searchBar.superview { container.frame = CGRectMake(container.frame.origin.x, container.frame.origin.y, container.frame.size.width, container.frame.size.height + app.statusBarFrame.height) } } }
Goal c
- (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection { [super traitCollectionDidChange: previousTraitCollection]; if(self.venueSearchController.active && ![UIApplication sharedApplication].statusBarHidden && self.venueSearchController.searchBar.frame.origin.y == 0) { UIView *container = self.venueSearchController.searchBar.superview; container.frame = CGRectMake(container.frame.origin.x, container.frame.origin.y, container.frame.size.width, container.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height); } }
pbasdf Feb 25 '15 at 15:04 2015-02-25 15:04
source share