- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; self.searchResults = [NSArray array]; UISearchbar *searchbar = [[UISearchbar alloc] init]; searchbar.barStyle = UISearchbarStyleDefault; searchbar.searchbarStyle = UISearchbarStyleDefault; searchbar.showsCancelbutton = YES; searchbar.showsScopebar = NO; searchbar.delegate = self; UISearchdisplayController *searchdisplayController = [[UISearchdisplayController alloc] initWithSearchbar:searchbar contentsController:self]; searchdisplayController.delegate = self; searchdisplayController.searchResultsDataSource = self; searchdisplayController.searchResultsDelegate = self; self.tableVIEw.tableheaderVIEw = searchbar;}- (voID)searchdisplayControllerWillBeginSearch:(UISearchdisplayController *)controller{ NSLog(@"searching"); //not showed up in the console}- (BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchString:(Nsstring *)searchString{ NSLog(@"%@",searchString); //not showed up in the console nspredicate *predicate = [nspredicate predicateWithFormat:@"name liKE %@",searchString]; NSArray *results = [Stock MR_findAllSortedBy:@"createdDate" ascending:NO withPredicate:predicate]; if ([results count] > 0) { self.searchResults = results; [self.searchdisplayController.searchResultstableVIEw reloadData]; } return YES;}解决方法 它不起作用,因为您正在将UISearchdisplayController创建为局部变量,这会导致在vIEwDIDLoad超出范围时将其解除分配.因此,为您的搜索显示控制器创建一个强大的属性,然后它应该正常工作(如果您将属性命名为searchdisplayController,则会遇到命名冲突,因此请将其称为其他内容). 总结
以上是内存溢出为你收集整理的ios – 未调用UISearchDisplayDelegate方法全部内容,希望文章能够帮你解决ios – 未调用UISearchDisplayDelegate方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)