有我的tableVIEwController;
import UIKitclass CitIEstableVIEwController: UItableVIEwController,UISearchResultsUpdating {// MARK: - Class PropertIEsprivate var citIEs = [String]()private var veterinarIEs = [Veterinary]()private var filteredVeterinarIEs = [Veterinary]()private var resultSearchController: UISearchController!// MARK: - tableVIEwController life Cycle MethodsoverrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() self.getCitIEsList() self.configureResultsSearchController()}overrIDe func vIEwDIDdisappear(animated: Bool) { super.vIEwDIDdisappear(animated) self.resultSearchController.active = false}// MARK: - Configuring Search bar Controllerprivate func configureResultsSearchController() { self.resultSearchController = UISearchController(searchResultsController: nil) self.resultSearchController.searchResultsUpdater = self self.resultSearchController.dimsBackgroundDuringPresentation = false self.resultSearchController.hIDesNavigationbarDuringPresentation = false self.resultSearchController.searchbar.sizetoFit() self.resultSearchController.searchbar.placeholder = "Klinik veya ilçe adı" self.tableVIEw.tableheaderVIEw = self.resultSearchController.searchbar}// MARK: - table vIEw data sourceoverrIDe func numberOfSectionsIntableVIEw(tableVIEw: UItableVIEw) -> Int { return 1 }overrIDe func tableVIEw(tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { if self.resultSearchController.active { return self.filteredVeterinarIEs.count } else { return self.citIEs.count }}// MARK: - table vIEw Delegate MethodsoverrIDe func tableVIEw(tableVIEw: UItableVIEw,dIDSelectRowAtIndexPath indexPath: NSIndexPath) { if (self.resultSearchController.active) { self.performSegueWithIDentifIEr(Constants.ShowDetailVIEwControllerSegueIDentifIEr,sender: nil) } else { self.performSegueWithIDentifIEr(Constants.ShowTownstableVIEwControllerSegueIDentifIEr,sender: nil) }}overrIDe func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr(Constants.CellIDentifIEr,forIndexPath: indexPath) if (self.resultSearchController.active) { cell.textLabel?.text = self.filteredVeterinarIEs[indexPath.row].name cell.detailTextLabel?.text = self.filteredVeterinarIEs[indexPath.row].address return cell } else { cell.textLabel?.text = self.citIEs[indexPath.row] return cell }}// MARK: - PARSE query Methodsprivate func getCitIEsList() { let parseQuerIEs = ParseQuerIEs() parseQuerIEs.downloadListData() { (let parseResults) in if let veterinarIEs = parseResults as? [Veterinary] { self.veterinarIEs = veterinarIEs for vet in veterinarIEs { if let city = vet.city { self.citIEs.append(city) } } dispatch_async(dispatch_get_main_queue()) { self.citIEs = HelperMethods().removeDuplicatesAndSort(array: self.citIEs) self.tableVIEw.reloadData() } } }}// MARK: - UISearchController Delegate Methodsfunc updateSearchResultsForSearchController(searchController: UISearchController) { self.filteredVeterinarIEs.removeAll(keepCapacity: false) if let searchbarText = searchController.searchbar.text{ let searchText = searchbarText.lowercaseString // Searching with Veterinary name and Veterinary City self.filteredVeterinarIEs = self.veterinarIEs.filter({self.definesPresentationContext = true.name?.lowercaseString.rangeOfString(searchText) != nil}) self.filteredVeterinarIEs += self.veterinarIEs.filter({.town?.lowercaseString.rangeOfString(searchText) != nil}) tableVIEw.reloadData() }}
这是来自iOS 9模拟器的黑屏图像,与真实设备相同.
当我点击searchbar并且它无法再次启动时,我认为它会消除我的tableVIEw.这是一个错误还是什么?
我怎么解决这个问题 ?
谢谢 !
解决方法 朋友,在你的vIEwDIDLoad()中插入以下代码行:看看我如何放(第29行):
click here to see
总结以上是内存溢出为你收集整理的ios – UISearchController导致黑屏Swift 2.0全部内容,希望文章能够帮你解决ios – UISearchController导致黑屏Swift 2.0所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)