Skip to content

yccheok/SearchBarIssue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

SearchBarIssue

I have a UICollectionView in red.

When I start to perform searching by entering the 1st character, I expect the result view controller (in yellow) will cover the entire UICollectionView.

It should not cover the top navigation bar.

But seems like this is not the case. May I know why?

My code is pretty straightforward.

import UIKit

class ViewController: UIViewController {

    lazy var searchController = UISearchController(searchResultsController: ResultVC())
    
    func ResultVC() -> UIViewController {
        let resultVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ResultVC") as UIViewController
        return resultVC
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        searchController.searchResultsUpdater = self
        searchController.obscuresBackgroundDuringPresentation = true
        searchController.searchBar.placeholder = "Search"
        searchController.searchBar.delegate = self
        navigationItem.searchController = searchController

    }
}


extension ViewController: UISearchBarDelegate {
}

extension ViewController: UISearchResultsUpdating {
    func updateSearchResults(for searchController: UISearchController) {

    }
}

0

1

2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages