Question

I´m programming an app on iOS5 ipad.

when a custom view finish load, on viewDidLoad, i call a function that set an aspect to some programically views like:

switch (interfaceOrientation) 
            {
                case UIDeviceOrientationPortrait:
                {
                    // Size 3 views using self.view.bounds.size.height
                    // and self.view.bounds.size.width
                    break;
                }
                case UIDeviceOrientationPortraitUpsideDown:
                {
                    // Size 3 views using self.view.bounds.size.height
                    // and self.view.bounds.size.width
                    break;
                }
                case UIDeviceOrientationLandscapeLeft:
                {
                    // Size 3 views using self.view.bounds.size.height
                    // and self.view.bounds.size.width
                    break;
                }
                case UIDeviceOrientationLandscapeRight:
                {
                    // Size 3 views using self.view.bounds.size.height
                    // and self.view.bounds.size.width
                    break;
                }

                default:
                    break;
            }

And i call that function on shouldAutorotateToInterfaceOrientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    [self setAspect:aspect];
    return YES;
}

When i rotate the app, put the views on the correct position, but, when is launched the app, if i have the ipad on Landscape, it don´t work correctly. It take the sizes of portrait. If i rotate the device, the problem is fixed, but i don´t like that problem in my app.

I don´t know why could be happening this, i have readed that call aspect on viewdidload is too early. Where must I call it the setAspect function?

Was it helpful?

Solution

I had this same issue today.

I ended up having to add: self.view.autoresizesSubviews = YES; to my viewDidLoad method, even though I had autoresize checked in Interface Builder.

-(void)viewDidLoad
{
    [super viewDidLoad];

    self.view.autoresizesSubviews = YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top