0

I use the following code to move up my view 20points when going to landscape:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)&&
   !UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
    NSLog(@"Going LandScape");
    self.view.frame = CGRectOffset(self.view.frame, 0, -20);
    //self.view.frame = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height);
}
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
    NSLog(@"Going Portrait");
    self.view.frame = CGRectOffset(self.view.frame, 0, 20);
}

}

On all devices except the iPhone 6 (and plus) devil creation, it works as intended, menu bar is keeping constrained and is 20points above(where the view ends) and looks like this at bottom in landscape: landscape, all devices but iphone6

now on the iPhone 6: landscape on iPhone 6/6plus

note, my menubar is placed within a view that is constrained to bottom of superview. I tried adding this code to viewDidLayoutSubviews in desperation:

    NSLayoutConstraint *bottomSpaceConstraint = [NSLayoutConstraint constraintWithItem:self.footerView
                                                                         attribute:NSLayoutAttributeBottom
                                                                         relatedBy:NSLayoutRelationEqual
                                                                            toItem:self.view
                                                                         attribute:NSLayoutAttributeBottom
                                                                        multiplier:1.0
                                                                          constant:0.0];
[self.view addConstraint:bottomSpaceConstraint];

that doesn't do anything either.

Please note that on the iPhone 6 the 20point gap is apparent BEHIND the menubar, so it is basically just not respecting the constraint. I have no idea why this only happens on the iPhone 6. Can anybody help me on the subject? Thanks in advance!

DevilInDisguise
  • 360
  • 1
  • 4
  • 14
  • `willRotateToInterfaceOrientation` is depracated in iOS 8. See http://stackoverflow.com/questions/25238620/ios-8-rotation-methods-deprecation-backwards-compatibility – cohen72 Dec 23 '14 at 13:11
  • I am running this on a 7.0. Anyway for later, if I want to make it 8.1 do I keep the deprecated methods and add the new ones as well? – DevilInDisguise Dec 23 '14 at 13:42
  • if you move to 8.1, you can stop using the deprecated methods, and using the new ones instead. Check out the reference for a more in depth explanation of all the tools you have available to you: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/willRotateToInterfaceOrientation:duration: – cohen72 Dec 23 '14 at 13:51

0 Answers0