В cellForRowAtIndexPath
добавьте свойство tag
к подпредставлению рассматриваемой ячейки. Также установите для свойства hidden
подпредставления значение YES
. Наконец, установите для ячейки selectionStyle
значение UITableViewCellSelectionStyleNone
.
if (thisIsTheIndexPathInQuestion) {
CGRect theFrame = CGRectMake(...); // figure out the geometry first
UIView *subview = [[UIView alloc] initWithFrame:theFrame];
// further customize your subview
subview.tag = kSubViewTag; // define this elsewhere, any random integer will do
subview.hidden = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubView:subview];
[subview release];
}
Затем просто отреагируйте на то, что вы описываете в соответствующем методе делегата UITableView:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (thisIsTheIndexPathInQuestion) { // you know how to check this
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIView *subview = [cell viewWithTag:kSubViewTag];
subview.hidden = !subview.hidden; // toggle if visible
}
}
Убедитесь, что ваша «специальная» ячейка имеет другой CellIdentifier
, и это будет работать.