ios searchbar SearchDisplayController

veryitman 2015-09-13 02:09:44
使用 searchbar 和SearchDisplayController来进行搜索和展示搜索结果, 但是SearchDisplayController使用之后,点击 searchbar 会弹出一层灰色的背景, 请问如何去掉这样的灰色背景遮罩层?
...全文
99 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
veryitman 2016-10-29
  • 打赏
  • 举报
回复
通过查看 UI 层级关系来解决.
self.dataList=[NSMutableArray arrayWithCapacity:1000]; for (NSInteger i=0; i<1000; i++) { [self.dataList addObject:[NSString stringWithFormat:@"010000----201200%ld",(long)i]]; } // Do any additional setup after loading the view from its nib. } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (tableView == self.searchDisplayController.searchResultsTableView) { return [self.searchList count]; }else{ return [self.dataList count]; } } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *flag=@"cellFlag"; UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:flag]; if (cell==nil) { cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag]; } if (tableView==self.searchDisplayController.searchResultsTableView) { [cell.textLabel setText:self.searchList[indexPath.row]]; } else{ [cell.textLabel setText:self.dataList[indexPath.row]]; } return cell; } //UISearchBarDelegate中德开始和结束的事件: - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{ NSLog(@"搜索Begin"); return YES; } - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar{ NSLog(@"搜索End"); return YES; } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString{ // 谓词的包含语法 NSPredicate *preicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[c] %@", searchString]; if (self.searchList!= nil) { [self.searchList removeAllObjects]; } //过滤数据 self.searchList= [NSMutableArray arrayWithArray:[_dataList filteredArrayUsingPredicate:preicate]]; //刷新表格 return YES; }

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧