1

我编写了下面的代码来为我的表格视图中的每个单元格添加 UILabel 的所有标题,但是我不确定如何继续。由于索引部分,我得到了错误。

先感谢您

- (IBAction)addAllCellLabelNamesToList:(UIButton *)sender {
    NSMutableArray*selected=[[NSMutableArray alloc]init];
    for (int i =0;i<[_mainTable numberOfRowsInSection:0];i++) {
        ListCell*cell=[_mainTable cellForRowAtIndexPath:i];//not usre what to put here
        if (!cell.isSelected) {//if selected add to array
            [selected addObject:cell.ingredientLabel.text];
        }
    }

}
4

1 回答 1

1

UITableViewDataSource#tableView:cellForRowAtIndexPath:接受一个NSIndexPath参数,而不是简单的int.

试试下面的代码:

[_mainTable cellForRowAtIndexPath:[NSIndexPath indexPathWithIndex:i]]
于 2013-01-17T19:28:49.623 回答