UISearchBar on iPad iPad disappears under navigation controller panel

I am working on a universal application using storyboards, and I added the UISearchBar and UISearchDisplayController to one of my table views. I plugged it all in and you can search in order. The problem is that I push the new view controller onto the navigation stack. On the iPhone, this is fine, but on the iPad it causes the shifted view controller to shift under the navigation bar (I had to manually make the navigation bar again so you can return).

Then, when you go back to the original view of the table in which the search was performed, the search is still active, but the UISearchBar now hiding behind the navigation bar, which means that there is no way to reject it without deleting the query. It also means that it is no longer in use, since you cannot return to it.

Probably best illustrated with some screenshots.

Here's what it looks like when you first open the table:

enter image description here

Then search in order:

Doing the search is fine

Going to the next screen, we can see the problem:

enter image description here

And then again on the home screen, continuing to search, but not the search box:

Search box half-buried

Then, if I remove everything from the search box and get rid of the overlay, I can see the search box when I look at the table view, but I can never reach it. I can't get a reliable screen capture, though.

I searched everywhere for a solution, but could not find it. I tried calling [self setNeedsDisplay] and [self setNeedsLayout] in the viewDidAppear method, but this seems to have no effect. It seems that he will correct himself if I change the orientation of the device, and I tried to reproduce what he would do in this situation by calling these methods.

IPad storyboard structure: SplitViewController → Navigation Controller → UITabBarControllerUITableViewController (contains UISearchBar , etc.) → UITableViewController

+4
source share
1 answer

I sent this problem to Apple DTS and they answered:

IPad storyboard structure: SplitViewController → Navigation Controller → UITabBarController → UITableViewController (contains UISearchBar, etc.) → UITableViewController

The fact is that your project architecture does not comply with our rules, which are: In the Mixed view controller interfaces section in the view controller directory for iOS: However, when combining view controllers, it is important to follow the containment order; only certain measures apply. The containment order, from child to parent, is as follows:

Content controllers and container view controllers that have flexible boundaries (such as a page view controller) Navigation view controller Tab panel controller Split image controller

Basically, you should have the following structure: SplitViewController -> UITabBarController -> Navigation Controller -> UITableViewController (contains UISearchBar, etc.) -> UITableViewController>

+1
source

Source: https://habr.com/ru/post/1402701/


All Articles