问题
I have 2 tableView
s at the moment.
One is a basic tableView
which shows cells and if selected, it goes into a detailed viewController
.
I created a new viewController
to create a filtered
page view. I populate my page view with a plist. I managed to create a filter but don't know how to proceed from here.
This is what I have:
- (IBAction)ingredientsAddButton:(UIButton *)sender
{
int j=0;
onemsiz.text=ingredientTextField.text;
ingredientText=onemsiz.text;
NSLog(ingredientText);
NSString *path = [[NSBundle mainBundle] pathForResource:@"recipes" ofType:@"plist"];
NSArray *arrayOfPlist = [[NSArray alloc] initWithContentsOfFile:path];
if (arrayOfPlist==NULL) {
}else {
for (int i=0; i<4; i++) {
// i currently have 4 element is plist.
NSString *strCurrentRecipeIngredients = [[arrayOfPlist objectAtIndex:i] objectForKey:@"recipeIngredients"];
NSString *strCurrentRecipeName = [[arrayOfPlist objectAtIndex:i] objectForKey:@"recipeName"];
//NSLog(@"%d. Loop \n", i+1);
if([strCurrentRecipeIngredients rangeOfString:(@"%@",ingredientText)].location!=NSNotFound) {
NSLog(@"%@ contains %@ ",strCurrentRecipeName, ingredientText);
NSLog(ingredientText);
NSLog(strCurrentRecipeIngredients);
j++;
}else {
NSLog(@"Not found");
NSLog(ingredientText);
NSLog(strCurrentRecipeIngredients);
}
if (ingredientText==NULL) {
NSLog(@"empty input");
}else {
}
}
}
NSLog(@"%d",j);
}
My first problem is how can I show the results in a tableView
?
回答1:
You create a table view and then create and assign its data source and delegate. If data in one of the table view needs to be changed when it is already displayed, the easy way to force it to update is call [tableView reloadData];
来源:https://stackoverflow.com/questions/22306047/how-to-show-filtered-table-view-in-ios