大佬教程收集整理的这篇文章主要介绍了iphone – UISearchDisplayController和自定义单元格,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
而且searchResultsTableView中的单元格没有触发segue ..
这是代码:
... - (NSInteger)tableView:(UITableView *)tableView @R_675_10793@erOfRowsInSection:(NSInteger)section { if (tableView == self.searchDisplayController.searchResultsTableView){ return [nameFilteredObj count]; } else { return [sortedObj count]; }} - (Customcatell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"customcatell"; Customcatell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[Customcatell 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作为界面.
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { ... self.searchDisplayController.searchResultsTableView.hidden=YES; return YES; }
以上是大佬教程为你收集整理的iphone – UISearchDisplayController和自定义单元格全部内容,希望文章能够帮你解决iphone – UISearchDisplayController和自定义单元格所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。