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:
Am I doing something wrong?
Any ideas and comments are welcome. Thanks a lot.
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
Last edited: