当我输入任何字符或单词时,键盘会卡住一段时间
这是代码
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()
}
}
这里是类似的问题keyboard stuck when searching in uitableview using uisearchbar...?