在UITableView中的部分中组织搜索控制器结果

时间:2011-05-04 18:41:26

标签: iphone objective-c

我有一个带有搜索栏的表视图(搜索显示控制器)我需要在各个部分组织结果...在开始时有1个部分,搜索结果可以有1或2或3个部分..你有一个很好的方法吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

取决于您捕获搜索结果的方式。

通常,您希望拥有NSArrays的NSMutableArray。这样你的主array.count就成了你的节数,行数变成了那个indexpath.row的嵌套数组的数量 一系列NSDictionaries也很典型。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return [mainArray count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [[mainArray objectAtIndex:section] count];

}
相关问题