3

I'm using TheSidebarController to implement add a sliding menu into an iOS application. This is the library I'm using, but I've found the same issue in other libraries, like ECSlidingViewController, etc. They essentially work by adding multiple view controllers onto a containing view controller, nothing too crazy.

The issue is, when you make the app a landscape app, all the screens in the container- the menu, the content screen- seem to think they're in portrait mode, and get cut off half way. You can see the issue in this screenshot where the table is cut off: http://imgur.com/xD5MUei

I've been trying to get this to work in any way I can, and no luck.
The library I'm using + example project can be found here: https://github.com/jondanao/TheSidebarController

Any help is greatly appreciated :)

EDIT: people are saying I can stretch the table out to make it look normal, but this just masks the underlying problem, which is the app and/or the screens still think they're in portrait orientation. As a quick example, if I take the example project, and in LeftViewController substitute the following code:

- (void)dismissThisViewController
{
  UIViewController* vc = [[UIViewController alloc] init];
  UINavigationController* pulldown = [[UINavigationController alloc] initWithRootViewController:vc];

  pulldown.view.frame = CGRectMake(pulldown.view.frame.origin.x, -[[UIApplication sharedApplication] delegate].window.frame.size.height,
                                   pulldown.view.frame.size.width, pulldown.view.frame.size.height);
  [[[UIApplication sharedApplication] delegate].window addSubview:pulldown.view];

  [UIView animateWithDuration:.5 animations:^{
    pulldown.view.frame = CGRectMake(pulldown.view.frame.origin.x, 0,
                                     pulldown.view.frame.size.width, pulldown.view.frame.size.height);
  } completion:^(BOOL finished) {
    ;
  }];
}

The viewcontroller comes in sideways, not from the top.

Adam
  • 1,486
  • 3
  • 20
  • 35

4 Answers4

2

This was a strange one... I had to set the frame of the content view controller, which made sense, but then I had to reset it every time the content was refreshed:

- (void)setContentViewController:(UIViewController *)contentViewController
{
    // Old View Controller
    UIViewController *oldViewController = self.contentViewController;
    [oldViewController willMoveToParentViewController:nil];
    [oldViewController.view removeFromSuperview];
    [oldViewController removeFromParentViewController];

    // New View Controller
    UIViewController *newViewController = contentViewController;
    [self.contentContainerViewController addChildViewController:newViewController];
    [self.contentContainerViewController.view addSubview:newViewController.view];
    [newViewController didMoveToParentViewController:self.contentContainerViewController];

    _contentViewController = newViewController;
    if ([DeviceDetection isDeviceiPad]) {
      _contentViewController.view.frame = CGRectMake(0, 0, 1024, 768);
    }
}
Adam
  • 1,486
  • 3
  • 20
  • 35
0

Did you check if it's has something to do with the new interface orientation?

https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html chapter -> Supporting New Screen Sizes and Scales

Michael
  • 1,030
  • 14
  • 29
0

In CenterViewController.h make the class a subclass of a UITableViewController instead.

Then comment out [self.view addSubview:self.tableView]; in CenterViewController.m.

Done!

carlodurso
  • 2,886
  • 4
  • 24
  • 37
  • this fixes how the table looks in this particular example, but it doesn't change that the underlying orientation is incorrect. As a quick example, if you try to present a viewcontroller on top of or leftviewcontroller, it comes in sideways, in portrait orientation – Adam Nov 03 '14 at 20:48
0

In centerViewController.m, when you create the tableview, add this line:

self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
gabbler
  • 13,626
  • 4
  • 32
  • 44
  • this fixes how the table looks in this particular example, but it doesn't change that the underlying orientation is incorrect. As a quick example, if you try to present a viewcontroller on top of or leftviewcontroller, it comes in sideways, in portrait orientation: – Adam Nov 03 '14 at 20:42