0

for reference, I am using Xcode 6.1 and targeting IOS 7.1. Looks like there are posts with similar problems but the suggestions have not worked for me. I have an app which I designed to work only in landscape mode. So I set the project to support only Landscape Right and Landscape Left orientation. But when in my code I want to present a new viewController, the app throws an exception and crashes at the "presentViewController" statement in the code below:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    PhotoViewController *photoVC = [storyboard
                                  instantiateViewControllerWithIdentifier:@"PhotoViewController"];
    // Configure the new view controller here.

    //photoVC.view.frame = CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height);

    photoVC.view.frame = CGRectMake(0,0,568, 320);

    [self presentViewController:photoVC animated:YES completion:nil];

By the way for testing purposes I hardwired 568 and 320 for the width and height.

The error message says:

uncaught exception 'NSInternalInconsistencyException', reason: 'Autolayout >doesn't support crossing rotational bounds transforms with edge layout >constraints, such as right, left, top, bottom. The offending view is: UITransitionView: 0x1701fa700; frame = (-2.84217e-14 0; 320 568); transform = [0, -1, 1, 0, 0, 0];

One thing I do not understand is why the "frame" in the error message shows 320 as width and 568 as height, when the "presentViewController" is passing a viewController with the frame set in landscape mode (width=568, height=320) . The error message also complains about "crossing rotational bounds transforms", which sort of hints that the viewController's view is being rotated?

any idea what is wrong?

thanks

malena
  • 798
  • 11
  • 26
  • Is your `PhotoViewController` actually set up to only allow landscape orientations, or are you relying strictly on setting the frame to do that for you (hint: it won't)? – Ian MacDonald Feb 12 '15 at 18:37
  • According to the ViewController Programming Guide when you specify at the application level that your application supports particular orientations , this choice applies to all viewControllers in the app. It says: "If you restrict the app’s supported orientations, then those restrictions apply globally to all of the app’s view controllers," But I also included the "supportedInterfaceOrientations" in the PhotoViewController to specify the that it supports landscape Right and Left, but the error is still the same – malena Feb 12 '15 at 21:45
  • Have you tried not explicitly setting the frame and letting the system do that for you? – Ian MacDonald Feb 12 '15 at 21:47
  • Yes, still I get the same problem. – malena Feb 12 '15 at 21:50

1 Answers1

0

After trial and error, I found out that setting the "setTranslatesAutoresizingMaskIntoConstraints" to NO was causing the problem. I used it in viewDidLoad of the presenting ViewController:

[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];

So I removed this statement. I used this statement to make sure I wouldn't have constraints conflicts between Interface Builders creation of automatic layout constraints and the auto layout constraints I added programmatically. So when I removed the statement I of course got constraints conflicts, but I eliminated them by "removing" existing constraints in viewDidLoad for every subview for which there were constraints conflicts. By the way, my programmatic constraints are called in "updateViewConstraints"

I do not completely understand why setting the setTranslatesAutoresizingMaskIntoConstraints to NO was causing the problem of not being able to present a new viewController modally, but my guess is that setting "setTranslatesAutoresizingMaskIntoConstraints" to YES is somehow needed for the system to figure out automatically the orientation and size of the presenting viewController.

malena
  • 798
  • 11
  • 26