Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 根据节标题筛选UITableView的整个节_Ios_Objective C - Fatal编程技术网

Ios 根据节标题筛选UITableView的整个节

Ios 根据节标题筛选UITableView的整个节,ios,objective-c,Ios,Objective C,我正试图找出解决这个问题的最佳方法。我有一个UITableView,其中可能有X个部分。我还有一个按钮,可以生成一个带有自定义UIPickerView的弹出窗口,该窗口显示每个部分的标题(我从数组中获取这些值,而不是UITableView,因为我不知道如何获取这些值) 当他们选择一个选项时,我想隐藏UITableView中的所有部分,很明显,除了带有所选选项标题的部分 我想知道你是否可以循环浏览所有的部分,看看它的标题,如果它与所选内容不匹配,就隐藏它?可能值得注意的是,将永远不会有超过10个部

我正试图找出解决这个问题的最佳方法。我有一个UITableView,其中可能有X个部分。我还有一个按钮,可以生成一个带有自定义UIPickerView的弹出窗口,该窗口显示每个部分的标题(我从数组中获取这些值,而不是UITableView,因为我不知道如何获取这些值)

当他们选择一个选项时,我想隐藏UITableView中的所有部分,很明显,除了带有所选选项标题的部分

我想知道你是否可以循环浏览所有的部分,看看它的标题,如果它与所选内容不匹配,就隐藏它?可能值得注意的是,将永远不会有超过10个部分,每个部分都有几个单元格,因此我不知道[table updateTable]或[table reloadData]是否更好

我的尝试:

//Filter out the notes that should display
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
//self.notesTable.dataSource = [myArrayOfDictionaries objectAtIndex:row]; 
//[self.notesTable reloadData]; this did not work

for (int section = 0; section < [notesTable numberOfSections]; section++){
    //find sections that don't match pickerview selection
    NSLog@("%@",[notesTable headerViewForSection:row);//return null?

}

}
//过滤掉应该显示的注释
-(void)pickerView:(UIPickerView*)pickerView didSelectRow:(NSInteger)row不完整项:(NSInteger)组件{
//self.notesTable.dataSource=[myArrayOfDictionaries对象索引:行];
//[self.notesTable reloadData];这不起作用
对于(int section=0;section<[notesTable numberOfSections];section++){
//查找与pickerview选择不匹配的节
NSLog@(“%@,[notesTable HeadServicewForSection:row);//返回null?
}
}

您能为您的
UITableView.delegate
UITableView.dataSource
方法发布代码吗

您希望执行以下操作:

  • 维护一个指向所有数据的
    @属性
    ,并维护另一个指向当前数据的
    @属性
  • 用户选择一个部分
  • 从allData中获取sectionData,将此sectionData设置为当前数据
  • 调用
    tableView上的
    reloadData
  • 确保您的
    委托
    数据源
    方法引用了
    当前数据
    @属性
上面这似乎不适用于您的原因是您正在设置
UITableView
dataSource=currentData
,这是不正确的。
dataSource
应始终设置为符合此协议的类(可能是您的
UIViewController