Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.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
Uitableview 如何在单击按钮时将tableview单元格accessorytype重置为none?_Uitableview_Nsindexpath - Fatal编程技术网

Uitableview 如何在单击按钮时将tableview单元格accessorytype重置为none?

Uitableview 如何在单击按钮时将tableview单元格accessorytype重置为none?,uitableview,nsindexpath,Uitableview,Nsindexpath,我正在尝试对重置按钮进行编码,这样当我单击该按钮时,所有tableview单元格的附件类型都会设置为none 我有一个明确的概念,如何做到这一点,但我是相当新的iPhone开发,所以我只需要帮助什么方法调用 我认为我需要采取的步骤是:我使用for循环遍历所有行,因此我计算单元格的数量(成功完成)。我的问题是,如果附件类型为复选标记并将其设置为none,我不知道如何检查这些行/单元格中的每一行/单元格 或者,我可以将所有单元格设置为accessoryne,但我已经在 - (void)tableVi

我正在尝试对重置按钮进行编码,这样当我单击该按钮时,所有tableview单元格的附件类型都会设置为
none

我有一个明确的概念,如何做到这一点,但我是相当新的iPhone开发,所以我只需要帮助什么方法调用

我认为我需要采取的步骤是:我使用for循环遍历所有行,因此我计算单元格的数量(成功完成)。我的问题是,如果附件类型为复选标记并将其设置为
none
,我不知道如何检查这些行/单元格中的每一行/单元格

或者,我可以将所有单元格设置为
accessoryne
,但我已经在

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

因此,我不确定如何实现这一点。

无需首先检查
附件类型是什么,只需将
UITableViewCellAccessoryNone
分配给所有附件。这应该适用于您正在尝试的操作:

// replace clickedResetButton with your action handler method for that button
- (IBAction)clickedResetButton:(id)sender {
    for (int section = 0, sectionCount = self.tableView.numberOfSections; section < sectionCount; ++section) {
        for (int row = 0, rowCount = [self.tableView numberOfRowsInSection:section]; row < rowCount; ++row) {
            UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.accessoryView = nill;
        }
    }
}
//将clickedResetButton替换为该按钮的操作处理程序方法
-(iAction)单击恢复按钮:(id)发件人{
对于(int section=0,sectionCount=self.tableView.numberOfSections;section
Swift 3.1

func resetAccessoryType(){
    for section in 0..<self.tableView.numberOfSections{
        for row in 0..<self.tableView.numberOfRows(inSection: section){
            let cell = self.tableView.cellForRow(at: IndexPath(row: row, section: section))
            cell?.accessoryType = .none
        }
    }
}
func resetAccessoryType(){
对于0中的节。。