As of iOS 11 beta 5, the search bar height isn't adjusting to make room for the scope buttons, so they appear under the search text input field.

In our app, when you click into the search bar on an iPhone, the scope buttons appear under the search text field instead of below it. After rotating the phone to Landscape, the scope buttons move to the right of the search text field, so they show correctly. When rotating back to Portrait, the scope buttons are hidden under the text field again.

This did not happen on with iOS 11 beta 4; it only started happening when we put iOS 11 beta 5 on a phone. We upgraded to beta 6 this week, and it still has the problem. (We have a phone still on beta 4, and the same version of the app works fine there.)


We add the search controller / search bar with scope buttons to UITableViewController in viewDidLoad:

- (void)viewDidLoad

{

[super viewDidLoad];

[...]

_searchResultsController = [[UITableViewController alloc] init];

_searchResultsController.tableView.dataSource = self;

_searchResultsController.tableView.delegate = self;

self.searchController = [[UISearchController alloc] initWithSearchResultsController:_searchResultsController];

self.searchController.searchResultsUpdater = self;

self.searchController.delegate = self;

self.searchController.dimsBackgroundDuringPresentation = YES;

self.searchController.searchBar.scopeButtonTitles = @[NSLocalizedString(@"From",@"From"),

NSLocalizedString(@"To",@"To"),

NSLocalizedString(@"Subject",@"Subject"),

NSLocalizedString(@"All",@"All")];



self.searchController.searchBar.delegate = self;

[self.searchController.searchBar sizeToFit];

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

self.definesPresentationContext = YES;


[..]

}


Is anyone else seeing this issue?

Rotating with search selected and scope bar visible still results in scope bar layered on top of search input when rotating back.

Any other fix ideas? Thank you!

Adding sizeToFit in willPresentSearchController was enough for me to get it to size properly. The scope buttons no longer hide under the textfield.


- (void)willPresentSearchController:(UISearchController *)searchController {

[self.searchController.searchBar sizeToFit];

}

Bug Report to Apple:

36091038


Table Search Field & Scope Buttons Broken In Xcode 9.2 SDK 11.2


Area: Xcode Summary: In Xcode 9.2 our app's Table Search/Scope Bar works (sort of with lots of work around coding when compiling for iOS 10.3 devices.


In Xcode 9.2 our app's Table Search/Scope Bar breaks when compiling with iOS 11.2 devices. (This trouble occurs in the landscape views on iPads).


It relates to when and where the search field scope buttons draw.


In iOS versions prior to 11.2 we got the scope buttons to draw adjacent to table search field. But with iOS 11.2 the scope buttons draw below table search field in landscape view now. The first time a table search is done, scope buttons do not draw or are invisible. (Perhaps overdrawn by the search field. The second time the table search is done the scope bar buttons do draw. Buttons draw below the search bar in both portrait and landscape views on iPads. now with sdk 11.2 code compilation on iOS 8+ targeted devices.


Before iOS 11.2 the scope buttons drew adjacent to and right of Table search field in the iPad landscape view. The change of scope button placement in iOS 11.2 is also overdrawing to top cell of table search results. In the landscape view selecting the returned top cell of search results will not drill down because it gets overdrawn by the scope buttons which are drawing below the table search field.


Steps to Reproduce:

Run an app built with a table search/scope function on an iPad that is running with code compiled with Xcode 9.2 iOS sdk 11.2. Compare the results of the UI with same app deployed to iPad target devices that have been compiled with earlier iOS like 10.3.


Expected Results:

The scope buttons should draw adjacent and to the right of the table search field. (During the initial and subsequent table searches including ability to drill down on the topmost table search result cell. The scope bar should not be overdrawn by the table search field. And in the lPad landscape view the scope bar should draw adjacent ant to the right of the search field...(The scope buttons should NOT draw below the Table search field and overdraw the top search result cell. Otherwise one cannot see the top table cell to drill down to content. And the scope buttons should be visible the first and all subsequent instances that the table search field is evoked. The scope buttons should NOT prevent drill-down selection of the top found cell table search result ... as is happening.

Actual Results:

In Xcode 9.2 our app's Table Search/Scope Bar breaks when targeting iOS 11.2. (This trouble occurs in the landscape views of iPad devices). It relates to when and where the search field scope buttons draw. In iOS versions prior to 11.2 the scope buttons drew adjacent to table search field. e.g. with Xcode 9.1 compiles. With iOS 11.2 the scope buttons draw below table search field in iPad landscape views. The first time a table search is done, scope buttons do not draw or are invisible. The second time the table search is done the scope bar buttons do draw but in the wrong place.

Version/Build: Xcode Version 9.2 (9C40b)

Configuration: iPads running iOS 11.2.1

This is still a problem in 11.2. I had a bug report in on this last September. Closed due to dupe, but still not fixed.

As of iOS 11 beta 5, the search bar height isn't adjusting to make room for the scope buttons, so they appear under the search text input field.
 
 
Q