Professional Documents
Culture Documents
FPNCountry List View Controller
FPNCountry List View Controller
// FPNCountryListViewController.swift
// FlagPhoneNumber
//
// Created by Aurélien Grifasi on 06/08/2017.
// Copyright (c) 2017 Aurélien Grifasi. All rights reserved.
//
import UIKit
tableView.tableFooterView = UIView()
initSearchBarController()
}
if #available(iOS 9.1, *) {
searchController.obscuresBackgroundDuringPresentation = false
} else {
// Fallback on earlier versions
}
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
} else {
searchController.dimsBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = true
searchController.definesPresentationContext = true
// searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
}
definesPresentationContext = true
}
cell.imageView?.image = country.flag
cell.textLabel?.text = country.name
if showCountryPhoneCode {
cell.detailTextLabel?.text = country.phoneCode
}
return cell
}
didSelect?(country)
searchController.isActive = false
searchController.searchBar.resignFirstResponder()
dismiss(animated: true, completion: nil)
}
// UISearchResultsUpdating
if countries.isEmpty {
results?.removeAll()
return
} else if searchController.searchBar.text == "" {
results?.removeAll()
tableView.reloadData()
return
}
// UISearchControllerDelegate