Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // disable touch on expanded cell
- UITableViewCell *cell = [self.theTableView cellForRowAtIndexPath:indexPath];
- if ([[cell reuseIdentifier] isEqualToString:@"ExpandedCellIdentifier"]) {
- return;
- }
- // deselect row
- [tableView deselectRowAtIndexPath:indexPath
- animated:NO];
- // get the actual index path
- indexPath = [self actualIndexPathForTappedIndexPath:indexPath];
- // save the expanded cell to delete it later
- NSIndexPath *theExpandedIndexPath = self.expandedIndexPath;
- // same row tapped twice - get rid of the expanded cell
- if ([indexPath isEqual:self.expandingIndexPath]) {
- self.expandingIndexPath = nil;
- self.expandedIndexPath = nil;
- }
- // add the expanded cell
- else {
- self.expandingIndexPath = indexPath;
- self.expandedIndexPath = [NSIndexPath indexPathForRow:[indexPath row] + 1
- inSection:[indexPath section]];
- }
- [tableView beginUpdates];
- if (theExpandedIndexPath) {
- [_theTableView deleteRowsAtIndexPaths:@[theExpandedIndexPath]
- withRowAnimation:UITableViewRowAnimationNone];
- }
- if (self.expandedIndexPath) {
- [_theTableView insertRowsAtIndexPaths:@[self.expandedIndexPath]
- withRowAnimation:UITableViewRowAnimationNone];
- }
- [tableView endUpdates];
- // scroll to the expanded cell
- [self.theTableView scrollToRowAtIndexPath:indexPath
- atScrollPosition:UITableViewScrollPositionMiddle
- animated:YES];
- }
- - (IBAction)expand:(id)sender {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement