में चयनित पंक्ति में मेरे पास UITableView
है जो पंक्ति का चयन करते समय चेकमार्क प्रदर्शित करता है। समस्या यह है कि जब मैं didSelectRowAtIndexPath
में एक पंक्ति का चयन करता हूं और चयनित पंक्ति पर एक चेकमार्क जोड़ता हूं तो यह एक अतिरिक्त चेकमार्क जोड़ता है। यहां मेरा कोडएकाधिक चेकमार्क जब UITableView IOS
कोई भी सहायता बहुत सराहना की जाएगी। अपने .m फ़ाइल में
प्रचार:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
// Configure the cell...
cell.textLabel.text=[[Model.category objectAtIndex:indexPath.row] categoryName];
cell.imageView.image=[[Model.category objectAtIndex:indexPath.row]categoryImage];
//cell.detailTextLabel.text [email protected]"Breve Descripción de la categoria";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if ([self.tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark) {
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType =UITableViewCellAccessoryNone;
[self.cellSelected removeObject:indexPath];
}else {
[tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
[self.cellSelected addObject:indexPath];
}
[self checkMark];
[tableView reloadData];
}
- (void)checkMark{
for (NSIndexPath * indexPath in self.cellSelected) {
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
}
}
क्यों है [tableView deselectRowAtIndexPath: indexPath एनिमेटेड: हाँ] आवश्यक है ?? जब मैं इस पंक्ति पर टिप्पणी करता हूं तो यह भी अच्छी तरह से काम करता है। – Klinkert0728
मुझे एक ही समस्या है, लेकिन एक छवि के साथ, मेरे पास प्रत्येक सेल के लिए एक छवि है और जब मैं एक पंक्ति का चयन करता हूं तो मुझे चयनित पंक्ति की छवि को बदलने की आवश्यकता होती है, लेकिन जब मैं इस छवि को बदलता हूं, तो एक और छवि परिवर्तन भी हो सकता है जब आप सेल को स्पर्श करते हैं तो आप हाइलाइट किए गए व्यवहार को हटाने के लिए – Klinkert0728
अचयनित कर सकते हैं। –