Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a property of the selected cell</p> <pre><code>@property (nonatomic) int currentSelection; </code></pre> <p>Then initialize it here</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.currentSelection = -1; } </code></pre> <p>In heightForRowAtIndexPath you can set the height you want for the selected cell</p> <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ int rowHeight; if ([indexPath row] == self.currentSelection) { rowHeight = 200; } else rowHeight = CURRENT_HEIGHT_HERE; return rowHeight; } </code></pre> <p>Then add you view here and hide it as:</p> <p>// Customize the appearance of table view cells.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; } UIView *myView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 200)]; myView.backgroundColor=[UIColor greenColor]; myView.tag=1001; [myView setHidden:YES]; [cell.contentView addSubview:myView]; // Configure the cell. return cell; } </code></pre> <p>In didSelectRow you save the current selection and save a dynamic height, if required</p> <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // do things with your cell here // set selection self.currentSelection = indexPath.row; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [[cell viewWithTag:1001] setHidden:NO]; // animate [tableView beginUpdates]; [tableView endUpdates]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload