I have two problems with
UISearchController
var resultSearchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
resultSearchController = UISearchController(searchResultsController: nil)
resultSearchController.searchResultsUpdater = self
resultSearchController.dimsBackgroundDuringPresentation = false
resultSearchController.hidesNavigationBarDuringPresentation = false
resultSearchController.searchBar.placeholder = "Traži.."
resultSearchController.searchBar.sizeToFit()
tableView.tableHeaderView = resultSearchController.searchBar
refreshControl = UIRefreshControl()
refreshControl!.attributedTitle = NSAttributedString(string: "Učitaj podatke..")
refreshControl!.backgroundColor = UIColor(red:1, green:0.48, blue:0, alpha:0.3)
refreshControl!.tintColor = UIColor.whiteColor()
refreshControl!.addTarget(self, action: #selector(ArticleTableViewController.getArticleData), forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl!)
}
UIRefreshControl
I found this solution:
override func viewDidLoad() {
super.viewDidLoad()
resultSearchController = UISearchController(searchResultsController: nil)
resultSearchController.searchResultsUpdater = self
resultSearchController.dimsBackgroundDuringPresentation = false
resultSearchController.hidesNavigationBarDuringPresentation = false
resultSearchController.searchBar.placeholder = "Traži.."
resultSearchController.searchBar.sizeToFit()
tableView.tableHeaderView = resultSearchController.searchBar
refreshControl = UIRefreshControl()
refreshControl!.attributedTitle = NSAttributedString(string: "Učitaj podatke..")
refreshControl!.backgroundColor = UIColor(red:1, green:0.48, blue:0, alpha:0.3)
refreshControl!.tintColor = UIColor.whiteColor()
refreshControl!.addTarget(self, action: #selector(ArticleTableViewController.getArticleData), forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl!)
// this hide search bar on next VC, first problem
self.definesPresentationContext = true
// second problem
tableView.contentOffset = CGPointMake(0, CGRectGetHeight(resultSearchController.searchBar.frame));
}