What does the searchDisplayController show scopeBar?

I know that there is a searchDisplayController.searchBar.showsScopeBar property, but in my search, even if we set showsScopeBar to NO, but set its searchDisplayController.searchBar.scopeButtonTitles property for some array, the area panel is displayed with the specified headers. Setting showsScopeBar to YES and setting scopeButtonTitles to nil does not show scopeBar .

So, I think the showsScopeBar property showsScopeBar really not useful, but showing or hiding the scopeBar actually depends on whether the array is set to the scopeButtonTitles property.

Is it possible? Or am I missing something else.

+4
source share
2 answers

Make sure your UISearchBar has room for expansion when the visibility bar appears. I made a mistake by having a UISearchBar inside a 320x44px fixed frame, and when the area panel was turned on, it just didn't have visible space (320x88px). Also, the UISearchBar was in the table header view, which also needs to be updated.

 [self.tableView beginUpdates]; [self.searchBar setShowsScopeBar:YES]; [self.tableView endUpdates]; 
+1
source

First, to be precise, shows the ScopeBar and scopeButtonTitles are properties of the UISearchBar class.

This happens as follows:

  • If scopeButtonTitles matters and showsScopeBar == NO
    The zoom buttons will only appear after the user clicks the Search text box.

  • If scopeButtonTitles is relevant and showsScopeBar == YES
    The zoom buttons are displayed even before the user clicks on the Search text box.
    (pretty ugly, don't go that way)

  • If scopeButtonTitles is nil The area buttons will not be displayed regardless of the showScopeBar value or user interaction.

You can use Interface Builder to play with it:
Click "Search Bar Controller" and go to the "Attributes" tab.

0
source

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


All Articles