Quantcast
Channel: UITableViewCell animate resize when user touchdown or tap Cell - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by Priyatham51 for UITableViewCell animate resize when user touchdown or tap Cell

$
0
0

Okay After reading through some doc and Going through WWDC videos's I was able to solve this.

I have learned a important thing.

Never use setFrame: on a view with AutoLayoutEnabled.

Keeping that in mind I changed my Custom UITableViewCell xib to use AutoResizing masks. And then in my UITableViewController I used these tableView:didHighlightRowAtIndexPath:tableView:didUnHighlightRowAtIndexPath: delegates

Here is the code snippet from my view Controller.

        -(void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath    {        NSLog(@"I'm Highlighted at %ld",(long)indexPath.section);        CustomTableViewCell *cell = (CustomTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];        originalCellSize = cell.frame;//Using animation so the frame change transform will be smooth.        [UIView animateWithDuration:0.1f animations:^{            cell.frame = CGRectMake(cell.frame.origin.x +20, cell.frame.origin.y, cell.frame.size.width-40, cell.frame.size.height);        }];    }    -(void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath    {        CustomTableViewCell *cell = (CustomTableViewCell *)[self.tableableView cellForRowAtIndexPath:indexPath];        [UIView animateWithDuration:0.1f animations:^{            cell.frame = CGRectMake(0, originalCellSize.origin.y, self.view.bounds.size.width, 180) ;        }];        originalCellSize = CGRectMake(0, 0, 0, 0);    }

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>