Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用searchdisplaycontroller swift2在tableview中搜索时键盘卡住_Swift2_Ios9_Uisearchcontroller - Fatal编程技术网

使用searchdisplaycontroller swift2在tableview中搜索时键盘卡住

使用searchdisplaycontroller swift2在tableview中搜索时键盘卡住,swift2,ios9,uisearchcontroller,Swift2,Ios9,Uisearchcontroller,当我输入任何字符或单词时,键盘会卡住一段时间 这是代码 func updateSearchResultsForSearchController(searchController: UISearchController) { menuView.hidden = true searchStr = searchController.searchBar.text temp = 1 if searchStr != "" { calledYoutub

当我输入任何字符或单词时,键盘会卡住一段时间

这是代码

  func updateSearchResultsForSearchController(searchController: UISearchController) {
    menuView.hidden = true
    searchStr = searchController.searchBar.text
    temp = 1

    if searchStr != ""
    {
      calledYoutubeAPI()
    }
    else
    {
      flag = 11
      noticeView.removeFromSuperview()
      tableView.reloadData()
    }

    let searchPredicate = NSPredicate(format: "SELF CONTAINS[cd] %@",searchStr)
    let arr = (videoName as NSArray).filteredArrayUsingPredicate(searchPredicate)
    self.videoName = arr as! [String]

        self.tableView.reloadData()
}


    func searchBar_Intialization()
{

    if flag == 0
    {
        self.resultSearchController = UISearchController(searchResultsController: nil)
        self.resultSearchController.dimsBackgroundDuringPresentation = false
        self.resultSearchController.searchBar.sizeToFit()
        self.resultSearchController.searchResultsUpdater = self
        self.resultSearchController.delegate = self
        self.resultSearchController.searchBar.placeholder = "Search Youtube & Library"
        self.resultSearchController.searchBar.searchBarStyle = UISearchBarStyle.Minimal
        self.tableView.tableHeaderView = self.resultSearchController.searchBar
        //self.edgesForExtendedLayout = UIRectEdge.None;
        self.tableView.reloadData()
    }

}

这里有一个类似的问题

您使用的是UIsearchController而不是搜索显示控制器!!!!!为什么要在一个位置而不是在其他位置重新加载主线程上的数据?当我删除dispatch_async然后问题无法解决在else条件下移动代码else,将最后4行代码移动到else块并删除else块中的重新加载数据调用尝试此操作但不起作用