I have a custom UITableViewController that detects when it's view's bounds change and uses that to update the number of thumbnails displayed per tableviewcell. However, when I embed the tableView inside of another view the bounds do not change, although I can confirm visually that it resizes.
I use KVO to detect when the bounds of the view changes. From inside my custom TableViewController's viewDidLoad method:
[self.view addObserver:self forKeyPath:@"frame" options:0 context:nil];
If I make my tableViewController the root view controller for the app and rotate the iPad the bounds are updated with each rotation, and all works perfectly.
However, with my tableview embedded in the nib of another view controller the bounds never gets updated - nor does the frame. Despite that, I can see that the tableview itself is resizing correctly as it rotates into/out of landscape mode - so somewhere in the app the real frame/bounds are changing, and just not being reported. Any idea how I can access what's really happening?
A better solution than KVO would be to implement viewDidLayoutSubviews
in your view controller. This is called on all bounds changes, once the layout is complete.
It turned out that in the interface builder file the tableview had lost it's referencing outlet as the tableViewController's view. Adding this back solved the problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With