title: How to add an accordion effect to UITableViewController?
body: <p>Here is the current screen:
  <img src="https://i.stack.imgur.com/lRY1F.png" alt="The current screen"></p>
  
  <p>As you can see, this is list of services that are provided. I retrieved the data from my company's api and the table view cells are populated dynamically.</p>
  
  <p>Here is how it is supposed to work:
  <img src="https://i.stack.imgur.com/HMKxq.jpg" alt="How it looks on Android">
  <img src="https://i.stack.imgur.com/SUNhX.jpg" alt="The desired functionality"></p>
  
  <p>On clicking one of the cells, an accordion like effect should expand the cell and reveal further details of a particular service. Clicking on it again or clicking on a different service should close it. How should I implement this? </p>
  
  <p>Here's the code for the <code>cellForRowAtIndexPath</code>:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ServiceCell" forIndexPath:indexPath];
  
  // Configure the cell...
  Service * serviceObject;
  serviceObject = [servicesArray objectAtIndex:indexPath.row];
  
  //Configuring the images
  Image * air = [[Image alloc] initWithLocation:@"icons/air.png" andWithServiceID:21];
  Image * pest = [[Image alloc] initWithLocation:@"icons/pest.png" andWithServiceID:18];
  Image * carpenter = [[Image alloc] initWithLocation:@"icons/carpenter" andWithServiceID:16];
  Image * laundry = [[Image alloc] initWithLocation:@"icons/laundry" andWithServiceID:20];
  Image * electrician = [[Image alloc] initWithLocation:@"icons/electrician.png" andWithServiceID:17];
  Image * plumber = [[Image alloc] initWithLocation:@"icons/plumber.png" andWithServiceID:14];
  Image * appliance = [[Image alloc] initWithLocation:@"icons/appliance.png" andWithServiceID:15];
  
  NSArray * images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:air.location], [UIImage imageNamed:pest.location], [UIImage imageNamed:carpenter.location], [UIImage imageNamed:laundry.location], [UIImage imageNamed:electrician.location], [UIImage imageNamed:plumber.location], [UIImage imageNamed:appliance.location], nil];
  
  if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:air.serviceID]]){
      cell.imageView.image = images[0];
  }else if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:pest.serviceID]]){
      cell.imageView.image = images[1];
  }else if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:carpenter.serviceID]]){
      cell.imageView.image = images[2];
  }else if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:laundry.serviceID]]){
      cell.imageView.image = images[3];
  }else if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:electrician.serviceID]]){
      cell.imageView.image = images[4];
  }else if([serviceObject.serviceID isEqualToNumber:[[NSNumber alloc] initWithInt:plumber.serviceID]]){
      cell.imageView.image = images[5];
  }else{
      cell.imageView.image = images[6];
  }
  
  //Setting the row labels
  cell.textLabel.text = serviceObject.serviceName;
  
  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  
  return cell;
  </code></pre>
  
  <p>}</p>
  
  <p>I'm currently using Xcode 6.3.2 with the latest iPhone SDK.</p>
  
  <p>Any help is appreciated. Thanks.</p>