views:

956

answers:

4

This is Portrait:

alt text

This is Landscape

alt text

I've tried this on rotation with no success:

self.tableView.autoresizesSubviews = YES;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
A: 

I looks like the table view is scrolled down a little after the orientation change.

Have you tried calling scrollToRowAtIndexPath:atScrollPosition:animated: and scrolling to the top-most row?

Ben S
No, it's not that cause when you sweep down it comes again under the Navigation Bar. In the down side there's also a toolbar with same results. The down part of tableView is under it in Landscape mode
Jorge
A: 

HI, I have the same problem, did you find a solution Jorge ?

Toto
I found a way to solve the probleme:self.tableView.contentInset = UIEdgeInsetsMake(13, 0, 0, 0);inwillRotateToInterfaceOrientation for landscape mode
Toto
Where did you put that code?I added the willRotateToInterfaceOrientation but it's never called
Jorge
I have a UIViewController (mainView) and a UITableViewController inside (navigationView).In the mainView, in willRotateToInterfaceOrientation, I call[navigationController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
Toto
So, I put self.tableView.contentInset = UIEdgeInsetsMake(13, 0, 0, 0) in the navigationController willRotateToInterfaceOrientation function
Toto
A: 

This problem can occur if you've called "willAnimateRotationToInterfaceOrientation:" in your navigation controller, but forgotten to call super from within the method.

You should have something like this:

        - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
        [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation];
// Your code here

    }
nzeltzer
If I add that code I get this warning when I compile:'UITableViewController' may not respond to '-willAnimateRotationToInterfaceOrientation:'
Jorge
The code snippet needs to go into your navigation controller, not your TVC.
nzeltzer
If I add that code I get this warning when I compile: 'UIViewController' may not respond to '-willAnimateRotationToInterfaceOrientation:' -Suchita
suchita
+2  A: 

I ran into this problem recently. In my case, it was because I was performing rotations of a navigation controller that was not the root controller of the application window. I was therefore using the rotate notification listener/affine transform/bounds adjustment approach to changing the layout of the navigation controller. This worked all right but produced the results described here. It took me a while to notice that when I rotated to landscape the nav bar's height was not being correctly resized (i.e., from 44 to 32 pixels, the framework's reduced height for landscape mode). The root view controller of my app was responding to willRotateToInterfaceOrientation and didRotateFromInterfaceOrientation, however. That view controller also already knew about the associated navigation controller. I remedied the problem by adding the following code to the willRotateToInterfaceOrientation method:

CGRect frame = self.navViewController.navigationBar.frame;
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
    frame.size.height = 44;
} else {
    frame.size.height = 32;
}
self.navViewController.navigationBar.frame = frame;

Hope this saves somebody some time in a similar situation.

jstevenco