1
votes

I have a simple page with a nav bar at the top, tab bar at the bottom, and a scrollview filling the space between. The scrollview contains a label and image and a non-scrollable textview that gets dynamically filled with text and sized appropriately. I've been trying to make it work in landscape by using:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        NSLog(@"called");
        navBar.frame = CGRectMake(0, 0, 480, 32);
        sview.frame = CGRectMake(0, 32, 480, 240);
    }
    else {
        navBar.frame = CGRectMake(0, 0, 320, 44);
        sview.frame = CGRectMake(0, 44, 320, 372);

    }

}

This gets me very close as the nav bar and scrollview resize correctly and it scrolls nicely, but the content within the scrollview is off to the left. How do I redraw the contents to line up correctly within the scrollview?

1
have you tried setting the autoresizemask? - Nick Weaver
I'm not sure how a method like the one above, and autoresizemask masks work together. I feel like when I start redrawing things with that method, the masks stop applying but I'm pretty new to this whole thing. Would I change the masks of the subviews or of the scrollview? - Ryan

1 Answers

1
votes

Nick provided the correct answer in his comment. I just had to change the autoresizemasks of the items in the scrollview. I did:

pic.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;

for each item in the viewDidLoad method.