当用户从表视图中取消选择该值时,我想在用户从表视图中选择行时设置按钮标题也从标题名称中删除。
这是我的代码。我只想选择 2 行。
UITableViewCell *thisCell = [tableView cellForRowAtIndexPath:indexPath];
if ([thisCell accessoryType] == UITableViewCellAccessoryNone)
{
if(i<2)
{
//thisCell.accessoryType = UITableViewCellAccessoryCheckmark;
[thisCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[selectedIndexes addObject:[catarray objectAtIndex:indexPath.row]];
[selectedIndexesTag addObject:[idtag objectAtIndex:indexPath.row]];
[btncat setTitle:[catarray objectAtIndex:indexPath.row]
forState:UIControlStateNormal];
i++;
}
else
{
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Error"
message:@"User Can only Select two values" delegate:self
cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
}
}
else
{
//thisCell.accessoryType = UITableViewCellAccessoryNone;
[thisCell setAccessoryType:UITableViewCellAccessoryNone];
[selectedIndexes removeObject:[catarray objectAtIndex:indexPath.row]];
[selectedIndexesTag removeObject:[idtag objectAtIndex:indexPath.row]];
i--;
}