在不解除SearchController的情况下无法转到VC

时间:2017-10-17 00:40:18

标签: ios swift tableview segue uisearchcontroller

如果没有关闭我的搜索控制器,我无法转换到我的View Controller。我的搜索控制器嵌入在我的TableView标头中。

有没有一种过渡方式而没有首先解雇我的搜索控制器?

以下是一些代码:

class ViewProfileViewController: UIViewController, UITableViewDelegate, 
UITableViewDataSource, UICollectionViewDelegateFlowLayout, 
UICollectionViewDataSource, UISearchBarDelegate, UISearchResultsUpdating {

let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
super.viewDidLoad()

searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.sizeToFit()
searchController.searchBar.searchBarStyle = .minimal
searchController.searchBar.placeholder = "Search City"
searchController.searchBar.showsCancelButton = true
searchController.searchBar.delegate = self
searchController.searchBar.backgroundColor = UIColor.white      
self.myTable.tableHeaderView = searchController.searchBar

}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: 
IndexPath) {
// Get rid of searchController
searchController.searchBar.endEditing(true)
searchController.isActive = false
searchController.dismiss(animated: true) { /* */ }

// Deselect row
tableView.deselectRow(at: indexPath, animated: true)

// Present your VC here
let mViewController = MController()
let navController = UINavigationController(rootViewController: 
mViewController)
present(navController,animated: true, completion: nil)

}

}

0 个答案:

没有答案