У меня раздел: 1 имеет 11 строк. Я устанавливаю такую высотуCell hidden property [tableView]
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) return 350;
else if (indexPath.section == 1) {
return 150;
}
else return 0;
}
если я установил cell.hidden = YES; как я могу удалить ячейку, потому что если cell.hidden = YES, это будет шоу-пространство, но я не хочу, чтобы это пространство было необходимо, если ячейка скрыта непосредственно удалять из secrion: 1
или если я могу установить высоту на каждые скрытые ячейки для 0.0
Благодарности
EDIT
нет NSArray для Tableview она настроена как этот
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) { return 1; }
else if (section == 1) {
int retype = [type intValue];
if (retype == 1 || retype == 5 || retype == 10) {
return 0;
}
else if (retype == 11) { return 9; }
else if (retype == 14) { return 4; }
else {
return 11;
}
}
else return 0;
}
и для ячейки настройки, как этот
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
int truef = [*nsstring* intValue];
if (indexPath.section == 1) {
if (indexPath.row == 0) {
if (truef == 0) {
cell.hidden = YES;
}
else {
cell.titleLabel.text = @"True";
}
}
}
EDIT 2
Это ошибка после использования deleteRowsAtIndexPaths
reason: 'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (11) must be equal to the number of rows contained in that section before the update (11), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out)
В какой момент вы решаете, когда показывать/отображать ячейку? –
Попробуйте получить ячейку, вызвав метод 'cellForRowAtIndexPath', тогда вы можете проверить свойство' hidden' –
Можете ли вы уточнить, почему вы хотите скрыть ячейки? Вы хотите скрыть вещи от пользователя? Данные, связанные с этими ячейками, больше не нужны или больше не существуют? – LudoZik