我正在創建一個具有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
好的。我在編輯我的問題。 –