0

For some reason, if I subclass ECSlidingViewContoller, it won't rotate (and neither will any subview).

Basically if I do this, popUpViewController.view won't rotate:

@interface DSlidingViewController : ECSlidingViewController

DPopUpViewController *popUpViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
[self addChildViewController:popUpViewController];
[self.view addSubview:popUpViewController.view];
[popUpViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];

NSDictionary *viewDictionary = @{@"view": popUpViewController.view};

NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:viewDictionary];
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|"
                                                                         options:0
                                                                         metrics:nil
                                                                           views:viewDictionary];
[self.view addConstraints:verticalConstraints];
[self.view addConstraints:horizontalConstraints];

But if I change the interface to this, everything works as expected. popUpViewController.view will rotate and occupy the whole screen. (But obviously this is no good since I need ECSliding).

@interface DSlidingViewController : UIViewController

So I have two questions:

  1. Is it possible to make this work? If so, what am I doing wrong?
  2. If it's not possible, then where should I add popUpViewController.view to to make it behave like a UIAlertView? (It must be shown above ECSliding's leftMenu and topView).
Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76

1 Answers1

0

You should either forward UIViewController's methods:

– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:

from your self controller to your sliding controller, or better implement controller containment through:

addChildViewController:
removeFromParentViewController
willMoveToParentViewController:
didMoveToParentViewController:

That would go like this:

self.popUpViewController = ...
[self addChildViewController: self.popUpViewController];
[self.view addSubview: self.popUpViewController.view];

For the latter approach, have a look at "Implementing a Container View Controller" section in UIViewController reference.

sergio
  • 68,819
  • 11
  • 102
  • 123