I’m implementing a search UX the place, when the person faucets into the search bar, your complete primary content material modifications to a distinct view (e.g., current searches, classes, or recommended queries). There’s no dim/blur overlay.
What I would like precisely
- Tapping the search bar replaces the display’s major content material (e.g., a listing/grid) with a devoted Search State view (strategies/current gadgets).
- UIKit-only (no SwiftUI), production-ready, with navigation bar remaining seen.
- Most important content material is UICollectionView
Questions
In UIKit, what’s the advisable sample to change your complete content material space when the search bar turns into first responder?
-
Use UISearchController with a resultsController, however host the “search state” view inside that outcomes controller and hold it seen even with empty question?
-
Use a guardian container VC and swap youngster VCs (MainContentVC ↔︎ SearchStateVC) on searchBarTextDidBeginEditing, then restore on cancel?
If utilizing UISearchController, how do I stop the standard overlay really feel and make it behave as a real content material swap (e.g., sizing/embedding the outcomes controller to exchange the primary content material area)?
Any caveats with keyboard focus, secure areas, and animation timing (e.g., definesPresentationContext, hidesNavigationBarDuringPresentation = false, or willPresentSearchController/willDismissSearchController)?
Purpose
A clear, UIKit-only resolution that swaps primary content material to a search-state view on focus (no blur/dim), updates stay whereas typing, and restores the unique content material on cancel — ideally leveraging finest practices (both UISearchController configured appropriately or a strong child-VC swap sample).