UITableView scroll content size incorrect after dismissing another view

cocoa-touch, ios, iphone, objective-c, uitableview

Solution

Add a

[table setNeedsDisplay]; 

Also, is there a particular reason why you are not animating?

Problem

So I have a `UITableViewController` which launches another `tableVC` which changes the number of cells for the original when dismissed. Upon dismissal, despite returning the correct cell height (and header height) as well as updated number of rows (such that the scroll content is huge), the scroll view only bounces when scrolled. Upon looking at the `contentSize` property of the scroll of the table, the `contentSize` is incorrect and is the same as it was previously. When initially loading the original `tableVC`, I do not have the problem. If I have a large number of cells, the table will scroll as expected. It is only upon dismissal of the presented `tableVC` that I run into the problem. One thing I am unsure of is when to call reloadData. I am doing it as follows: 1. in presented `tableVC`: ``` [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil] ``` 2. in original tableVC: ``` -(void)viewDidAppear { //tablecell number manipulated [table reloadData]; } ``` The funny thing is if I rotate to landscape and back to portrait, the contentSize is then set correctly and I can scroll again.

Original source