如何在iOS中显示过滤后的表格视图? [英] How to show filtered table view in iOS?

查看:100
本文介绍了如何在iOS中显示过滤后的表格视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有2个tableView.
一个是基本的tableView,其中显示了单元格,如果选中,则会进入详细的viewController.

I have 2 tableViews at the moment.
One is a basic tableView which shows cells and if selected, it goes into a detailed viewController.

我创建了一个新的viewController以创建一个filtered页面视图.我用plist填充页面视图.我设法创建了一个过滤器,但不知道如何从这里继续.

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.

这就是我所拥有的:

- (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);
}

我的第一个问题是如何在tableView中显示结果?

My first problem is how can I show the results in a tableView?

推荐答案

您创建了

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];

这篇关于如何在iOS中显示过滤后的表格视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆