I am seeing a really weird issue and cant figure out what the heck is going on....
I am presenting a modalviewcontroller in my application and the first time i do this everything is fine, but after that the size is getting adjusted very oddly. It looks like everything is getting pushed to the right by about 20 points, but only in landscape mode (sometimes everything is pushed to the left by about 20 points too). If I rotate, it goes back to its proper placement.
The only two places i am setting the frames for my ui elements are in viewWillAppear and shouldAutorotateToInterfaceOrientation. I printed the frame width, height, x and y in viewWillAppear and this is what I get:
First time displayed (portrait) - 320.000000 460.000000 0.000000 20.000000
Second time displayed (portrait) - 320.000000 460.000000 0.000000 20.000000
Third time displayed (landscape) - 480.000000 300.000000 0.000000
20.000000 (PROBLEM)
I've tried everything I can think of and cant figure out what the heck is going on. Any ideas?
Here is the code where I am adjusting the position of UI elements (viewWillAppear and shouldAutoRotatetoInterface):
Code:
// setting up the view for when it becomes visible.
if (([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight))
{
// position input view and logo image.
[inputView setFrame:CGRectMake(150, 46, 320, 176)];
[loginImage setFrame:CGRectMake(18, 69, 124, 130)];
}
else
{
// position input view and logo image.
[inputView setFrame:CGRectMake(0, 61, 320, 176)];
[loginImage setFrame:CGRectMake(98, 264, 124, 130)];
}
I already had the autoresizing turned off.
I just tried adding [self.view setAutoresizingMask:UIViewAutoresizingNone]; to viewDidLoad and viewWillAppear, and it doesn't seem to make any difference.
So I made a small bit of progress on this issue. If i add the following lines of code, I no longer see the issue, BUT I want to keep the status bar visible in my app, so I can't use this as a fix.