Question

When I switch navigationBar to translucent, my UISearchDisplayController went crazy.

The dimmed area is missplaced by 64px, same for first row in results table. I know how to fix resultTableView missplacement, but I cannot find a way to fix dimmed area frame.

Strangely enough I found that my main view is in origin.y = 64.0f when translucent is set to YES. It happens somewhere in between viewDidLoad, viewDidAppear. If I change it it works, but than transitions between views in navigations controller are broken.

enter image description here

=============

Problem solved by: extendedLayoutIncludesOpaqueBars

Was it helpful?

Solution

Check the search bar's AutoLayout/AutoResizingMask settings.

Also make sure you're not manually modifying the bar's frame as the system will try to animate the bar into its position along the dimmed view and results' table view.


When you set the translucent property and automaticallyAdjustsScrollViewInsets to YES (default): a) the view gets stretched under the navigation bar and b) a top contentInset is added to the underlying UIScrollView (table view is a subclass).

My guess is that only b) is happening in your case for some reason. You can try to solve it by either:

  • Clear automaticallyAdjustsScrollViewInsets.
  • Removing the automatically added contentInset from your scroll view.
  • Setting your controller to do a) even with opaque bars by setting extendedLayoutIncludesOpaqueBars.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top