Make sure that the search bar doesn't appear on device rotation. Issue #1171

This commit is contained in:
Maurice Parker 2019-10-24 12:46:53 -05:00
parent bedf8a19e9
commit 3f81cd9b96
1 changed files with 15 additions and 14 deletions

View File

@ -48,20 +48,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
// Setup the Search Controller
searchController.delegate = self
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = NSLocalizedString("Search Articles", comment: "Search Articles")
searchController.searchBar.scopeButtonTitles = [
NSLocalizedString("Here", comment: "Here"),
NSLocalizedString("All Articles", comment: "All Articles")
]
navigationItem.searchController = searchController
definesPresentationContext = true
// Setup the Refresh Control
refreshControl = UIRefreshControl()
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
@ -85,6 +71,21 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
updateProgressIndicatorIfNeeded()
}
override func viewWillLayoutSubviews() {
// If you setup the Search Controller in viewWillLayoutSubviews it won't show by default on creation
searchController.delegate = self
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = NSLocalizedString("Search Articles", comment: "Search Articles")
searchController.searchBar.scopeButtonTitles = [
NSLocalizedString("Here", comment: "Here"),
NSLocalizedString("All Articles", comment: "All Articles")
]
navigationItem.searchController = searchController
definesPresentationContext = true
}
// MARK: Actions
@IBAction func markAllAsRead(_ sender: Any) {