/ Published in: Objective C

Expand |
Embed | Plain Text
#pragma mark - #pragma mark Table view data source // Customize the number of sections in the table view. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return (tableView==tblMain)?[self.arFoodData count]:[self.arFilteredFoodData count]; } return 141.0f; } #define kTagForCellView 1 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; [cell setBackgroundColor:[UIColor clearColor]]; [cell setAutoresizesSubviews:NO]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; } UIView *v=[cell viewWithTag:kTagForCellView]; if(v) { [v removeFromSuperview]; v = nil; } CCellView *c=[[arr objectAtIndex:indexPath.row] valueForKey:@"CCellView"]; if(c.view) [c viewDidLoad]; c.view.tag=kTagForCellView; [cell addSubview:c.view]; return cell; } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString]; return YES; } [arFilteredFoodData removeAllObjects]; NSRange r=[[d valueForKey:@"title"] rangeOfString:searchText options:NSCaseInsensitiveSearch]; if(r.length>0)[arFilteredFoodData addObject:d]; } }
You need to login to post a comment.