I have a UITableViewController and DetailViewController that pops up when concrete row is selected. The problem is the tableView does not call “didRotateFromInterfaceOrientation” method when rotation is did in DetailViewController. It’s logical, however I need to reload a table if orientation has changed.
I’m trying this code but it doesn’t work:
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
if (self.interfaceOrientation != [UIDevice currentDevice].orientation){
[self handleTableViewRotation];
}
}
I’m assuming there should be some property that holds orientation of tableView that is independent of current device orientation property…
Maybe the most elegant solution is coding a protocol. Whenever your
DetailViewControllerenters in a rotation callback, callreloadDatamethod of your tableView.Or… you can continue that way. In that case you have to store the tableViewController’s last orientation as a instance var and compare it to the current. After that, remember setting the new orientation
EDIT: First declare a new Protocol.
In your DetailViewController.h:
In DetailViewController.m:
Now your ViewController that contains the tableView:
And finally implement
didRotatemethod and call[yourTableView reloadData]inside. Remember that you have to set the rotation delegate after init your DetailViewController.