Reputation: 357
I am fairly new to iOS development and just inherited bunch of iOS code.
I am trying to start using auto layout and constraints to make it easier to support different screens sizes and iOS versions. I find that once I change storyboard to use an auto layout, background image no longer change when I rotate the iPad into landscape view. I am not sure if this is auto layout preventing this change or is there some other way to switch the background image. I'd appreciate your help.
Here is my rotate method.
- (void)didRotate
{
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhone)
{
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
{
[backgrndView setBackgroundImage:[UIImage imageNamed:@"menu_ipad2.png"] forState:UIControlStateNormal] ;
}
else if (orientation == UIDeviceOrientationPortraitUpsideDown|| orientation == UIDeviceOrientationPortrait)
{
[backgrndView setBackgroundImage:[UIImage imageNamed:@"menu_ipad.png"] forState:UIControlStateNormal] ;
}
[backgrndView sizeToFit];
}
}
Upvotes: 1
Views: 954
Reputation: 357
Adding new left, right and top constraints of value zero to the underlying view (which was a button) fixed the problem.
Upvotes: 1
Reputation: 41226
I believe the method you're looking to override is didRotateFromInterfaceOrientation:
not didRotate
Upvotes: 0