Tôi đã thực hiện một tableView trong đó tôi cần phải chọn nhiều tùy chọn. Các tùy chọn được chọn nhưng khi tôi cuộn chế độ xem bảng, tùy chọn dấu kiểm sẽ biến mất và một số hàng khác hiển thị dấu kiểm đó. Đây là mã của tôi trong didselectedrowAtindex
phương pháp table_option
là UITableView
và selectedcells
là NSMutableArray
Loại phụ kiện UITableview biến mất khi di chuyển
[table_option deselectRowAtIndexPath:indexPath animated:YES];
NSNumber *rowNsNum = [NSNumber numberWithUnsignedInt:indexPath.row];
if ([selectedCells containsObject:rowNsNum] )
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells removeObject:rowNsNum];
[email protected]"Select";
// cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells addObject:rowNsNum];
[email protected]"Selected";
// cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[table_option reloadData];
pls help sớm
Awesome, cảm ơn rất nhiều .. này giải quyết vấn đề ... nhờ một lần nữa – wasim
Với niềm vui. Cảm ơn bạn đã bình luận. :) –
"containsObject", đây là chìa khóa, giúp tôi tiết kiệm rất nhiều tác phẩm. –