Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cthesky

macrumors member
Original poster
Aug 21, 2011
91
0
Hi all,

I am developing an IPad application. I have 2 views, there are firstViewController and secondViewController. In my firstViewController, it has a button on this view, when click on the button, the secondViewController will be displayed. Both of this view should support landscape and portrait orientation.

So, when I test run in IPad device, at first I start my application in Portrait mode, and then switched to landscape mode, both first and secondViewController can be displayed and switch nicely from Portrait to Landscape.

But I face a problem when I test another scenario. That is when I start my application in landscape mode, the firstViewController can be displayed properly in Landscape mode. But when I click on the button, the secondViewController can be autorotated but cannot autoresized to Landscape mode. It make the right part of the secondViewController is blank. I had set up the autosizing property in the Size Inspector of interface builder to make the secondViewController can autoresize based on current device orientation. But the problem still happens. Am I doing something wrong? I had attached a picture for this scenario. I don't know why this happens. Anyone know how to solve this problem?

After some try, I added some code in viewDidLoad(). It seems can solve my problem but I am not sure whether this is a correct solution. Hope someone can give me some ideas.

Here is what I done:
Code:
- (void)viewDidLoad
{
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
        
{
     self.view.frame = CGRectMake(0, 0, 768, 1004);      
} 
else 
{
     self.view.frame = CGRectMake(0, 0, 1024, 748);
}
}

Am I doing something wrong?

Any ideas and comments are welcome. Thanks a lot. :)
 

Attachments

  • LandscapeViewProblem.png
    LandscapeViewProblem.png
    34 KB · Views: 68
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.