A
A
AlexxOrlovv2017-10-23 21:48:58
iOS
AlexxOrlovv, 2017-10-23 21:48:58

In ios11 searchBar's scopeButtons doesn't render correctly in tableHeaderView?

Good day, I'm learning to make IOS applications. Unfortunately, I did not find a decent book on ios11 - I am studying at https://www.ozon.ru/context/detail/id/140304577/. before that I mastered 4 Swift. There are some inconsistencies with api occasionally, but usually the problem with finding an analogue is solved in a couple of minutes.
Faced a problem
59ee3869c2ede959253171.png

@IBOutlet weak var tableView: UITableView!
    let sectionsTableIdentifier = "SectionsTableIdentifier"
    var names: [String: [String]]!
    var keys: [String]!
    var searchController: UISearchController!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: sectionsTableIdentifier)
        
        let path = Bundle.main.path(forResource: "sortednames", ofType: "plist")
        let nameDist = NSDictionary(contentsOfFile: path!)
        names = nameDist as! [String:[String]]
        keys = (nameDist!.allKeys as! [String]).sorted()
        
        
        let resultsController = SearchResultsController()
        resultsController.names = names
        resultsController.keys = keys
        searchController = UISearchController(searchResultsController: resultsController)

        let searchBar = searchController.searchBar
        
        searchBar.scopeButtonTitles = ["All", "Short", "Long"]
        searchBar.placeholder = "Enter a search term"
        
        searchBar.sizeToFit()
        tableView.tableHeaderView = searchBar
        
        searchController.searchResultsUpdater = resultsController
    }

Judging by the book in ios10, this should be displayed completely without any problems. But in the latest version, scopeButtons are not fully visible.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question