
- (voID)prepareForSegue:(UIStoryboardSegue *)segue sender:(ID)sender { 而且searchResultstableVIEw中的单元格没有触发segue ..
如何使用自定义单元格和segue工作显示搜索结果?
这是代码:
...- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{if (tableVIEw == self.searchdisplayController.searchResultstableVIEw){ return [nameFilteredobj count];} else {return [sortedobj count];}}- (CustomCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{static Nsstring *CellIDentifIEr = @"customCell";CustomCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr];if (cell == nil) {cell = [[CustomCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:CellIDentifIEr];}if (tableVIEw == self.searchdisplayController.searchResultstableVIEw){cell.textLabel.text = [[sortedobj objectAtIndex:indexPath.row] valueForKey:@"name"]; } else {cell.nameLabel.text = [[sortedobj objectAtIndex:indexPath.row] valueForKey:@"name"];cell.countryLabel.text = [[sortedobj objectAtIndex:indexPath.row] valueForKey:@"Country"];cell.bottleImageVIEw.image = [UIImage imagenamed:[[sortedobj objectAtIndex:indexPath.row] valueForKey:@"Image"]];} return cell; }//The codes for filtering the results and update of searchResultstableVIEw (not necessary for this question I think):- (voID)filterContentForSearchText:(Nsstring*)searchText scope:(Nsstring*)scope{[nameFilteredobj removeAllObjects];for(NSDictionary *obj in sortedobj){Nsstring *objname = [obj objectForKey:@"name"];NSRange range = [objname rangeOfString:searchText options:NSCaseInsensitiveSearch];if (range.location != NSNotFound) { [nameFilteredobj addobject:obj];}}}- (BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchString:(Nsstring *)searchString{[self filterContentForSearchText:searchString scope: [[self.searchdisplayController.searchbar scopebuttonTitles] objectAtIndex:[self.searchdisplayController.searchbar selectedScopebuttonIndex]]];return YES;}- (BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchScope:(NSInteger)searchOption{[self filterContentForSearchText:[self.searchdisplayController.searchbar text] scope: [[self.searchdisplayController.searchbar scopebuttonTitles] objectAtIndex:searchOption]];return NO;}... 我正在使用Storyboard作为界面.
解决方法 实际上很容易做到,但我发现了许多复杂的半工作解决方案.使用这个简单的部分,SearchResultstableVIEw是GONE:- (BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchString:(Nsstring *)searchString{...self.searchdisplayController.searchResultstableVIEw.hIDden=YES;return YES;} 总结 以上是内存溢出为你收集整理的iphone – UISearchDisplayController和自定义单元格全部内容,希望文章能够帮你解决iphone – UISearchDisplayController和自定义单元格所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)