Я работаю над множественным выбором tableview, снимите выделение.UITableViewCellAccessoryCheckmark исчезнет после прокрутки стола.
У меня 3 вида таблицы (Tableview которые имеют тег 400, мне нужно множественный выбор и отмену выбора -> alllMumbaiTableview)
Мой вопрос: Когда я выбрать несколько строк, UITableViewCellAccessoryCheckmark
прибудет исчез после прокрутки таблицы. Но вот здесь я вижу, что эти ячейки все еще находятся в только в выбранном состоянии, но не отображаются UITableViewCellAccessoryCheckmark
.
После прокрутки мой стол выглядит как этот
Вот мой код
@property (nonatomic, strong) NSMutableArray *arrIndexpaths;
UITableView M ethods -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(tableView.tag == 100)
{
cell.textLabel.text = [typeArray objectAtIndex:indexPath.row];
}
else if (tableView.tag == 300)
{
cell.textLabel.text = [specialityArray objectAtIndex:indexPath.row];
}
else if (tableView.tag == 400)
{
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
if ([self.arrIndexpaths containsObject:[NSIndexSet indexSetWithIndex:indexPath.row]])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.textLabel.text = [allMumbaiArray objectAtIndex:indexPath.row];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView.tag == 100)
{
_typeTextfield.text=[typeArray objectAtIndex:indexPath.row];
_typeTableview.hidden = YES;
}
else if (tableView.tag == 300)
{
_specialityTextield.text=[specialityArray objectAtIndex:indexPath.row];
_specialityTableview.hidden = YES;
}
else if (tableView.tag == 400)
{
UITableViewCell *tableViewCell = [tableView cellForRowAtIndexPath:indexPath];
tableViewCell.accessoryType = UITableViewCellAccessoryCheckmark;
[self.arrIndexpaths addObject:[NSIndexSet indexSetWithIndex:indexPath.row]];
}
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag == 400)
{
UITableViewCell *tableViewCell = [tableView cellForRowAtIndexPath:indexPath];
tableViewCell.accessoryType = UITableViewCellAccessoryNone;
[self.arrIndexpaths removeObject:[NSIndexSet indexSetWithIndex:indexPath.row]];
}
}
Что я хочу:
1) Я хочу UITableViewCellAccessoryCheckmark
даже после прокрутки TableView (Но не получить выбранный другие строки, когда я выбирая один. Моя предыдущая проблема ->Selecting one UITableViewCell selects the other cell after scrolling)
2) Мне нужны все только выбранные значения в один массив.
Я не получаю .. может у пожалуйста, обновить ваш код в отношении моего кода? –
обновил мой код, как и сказал, но все равно столкнулся с тем же –
Вы проверили, что if ([self.arrIndexpaths containsObject: [NSIndexSet indexSetWithIndex: indexPath.row]]) отлично подходит? – jamesBlake