我正在创建一个具有pickerView的自定义单元格,当我运行该应用程序时,它会使用选取器视图加载所有单元格。一次有4个单元格可见,当我更改第一个选择器视图的值并向下滚动时。每个第四选择器的价值已经改变。我得到所有选择器视图的值,它返回正确的值,意味着它只改变第一个选择器视图的值。dequeueReusableCellWithIdentifier更改多个UIPickerviews值
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AddTaskTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"addTaskCell" forIndexPath:indexPath];
AddTaskDetails *task =[self.tasksArray objectAtIndex:indexPath.row];
NSAttributedString *attributedString = [self attributedTextForTask:task.taskDetail];
cell.taskDetails.attributedText = attributedString;
cell.hourePicker.tag = indexPath.row;
[cell.hourePicker selectRow:0 inComponent:0 animated:YES];
cell.addDescriptionBtn.tag = indexPath.row;
[cell.addDescriptionBtn addTarget:self action:@selector(didTapAddDescButton:) forControlEvents:UIControlEventTouchUpInside];
return cell; }
我已经做到了。但现在,如果我滚动我的tableview它将所有选择器视图重置为默认值。 –
你能提供你的方法去除细胞吗? 你在哪里存储在选择器中选择的值? – anierzad
好的。我在编辑我的问题。 –