mikefrederick / MFSideMenu

Facebook-like side menu for iOS
Other
1.17k stars 291 forks source link

MFSideMenuDemoBasic Menu does not scroll completely when started in Landscape Mode in iPad #139

Closed mattbond closed 10 years ago

mattbond commented 10 years ago

If you start (and I don't mean resume) the MFSideMenuDemoBasic App with the iPad in Landscape mode then you can't scroll the left or right menus to the bottom. All items below section 1 item 5 are off screen. It looks like the view has 1024 height instead of 768 and thus the rest is off screen.

screen shot 2013-11-26 at 14 47 47

if you increase the number of items per section to 20 in the sample then the menu stops at Section 1 Item 13

screen shot 2013-11-26 at 14 56 57

By Adding this code to SideMenuViewController.m and forcing a Memory Warning in the Simulator (Menu: Hardware, Simulate Memory Warning) for the demo App, started in Landscape, with the left-Menu open: we can see the View/Window hierarchy and see that just the UITableView has the incorrect height its parent & predecessors all have 748 (768 - statusBar on iOS 6.1)

- (void)didReceiveMemoryWarning {
    //[super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    NSLog(@"START");

    UIView *aView = self.view;
    do {
        NSLog(@"Bounds %@ %f %f %f %f", aView.class, aView.bounds.origin.x, aView.bounds.origin.y, aView.bounds.size.width, aView.bounds.size.height);
        NSLog(@"Frame  %@ %f %f %f %f", aView.class, aView.frame.origin.x, aView.frame.origin.y, aView.frame.size.width, aView.frame.size.height);

        aView = aView.superview;
    }
    while (aView);
}
2013-11-26 15:09:05.021 MFSideMenuDemoBasic[68838:907] START
2013-11-26 15:09:05.021 MFSideMenuDemoBasic[68838:907] Bounds UITableView 0.000000 0.000000 270.000000 1024.000000
2013-11-26 15:09:05.022 MFSideMenuDemoBasic[68838:907] Frame  UITableView 0.000000 0.000000 270.000000 1024.000000
2013-11-26 15:09:05.022 MFSideMenuDemoBasic[68838:907] Bounds UIView 0.000000 0.000000 1024.000000 748.000000
2013-11-26 15:09:05.022 MFSideMenuDemoBasic[68838:907] Frame  UIView 0.000000 0.000000 1024.000000 748.000000
2013-11-26 15:09:05.022 MFSideMenuDemoBasic[68838:907] Bounds UIView 0.000000 0.000000 1024.000000 748.000000
2013-11-26 15:09:05.023 MFSideMenuDemoBasic[68838:907] Frame  UIView 20.000000 0.000000 748.000000 1024.000000
2013-11-26 15:09:05.023 MFSideMenuDemoBasic[68838:907] Bounds UIWindow 0.000000 0.000000 768.000000 1024.000000
2013-11-26 15:09:05.023 MFSideMenuDemoBasic[68838:907] Frame  UIWindow 0.000000 0.000000 768.000000 1024.000000
mattbond commented 10 years ago

One workaround is to use the superview frame rather than the view frame in setLeftSideMenuFrameToClosedPosition and setRightSideMenuFrameToClosedPosition Tested on iOS 6.1 & 7.03 Simulators iPhone & iPad (I don't have a 5.1 Sim on my Mac anymore)

 - (void) setLeftSideMenuFrameToClosedPosition {
     if(!self.leftMenuViewController) return;
-    CGRect leftFrame = [self.leftMenuViewController view].frame;
+    CGRect leftFrame = [self.leftMenuViewController view].superview.frame;
     leftFrame.size.width = self.leftMenuWidth;
     leftFrame.origin.x = (self.menuSlideAnimationEnabled) ? -1*leftFrame.size.width / self.menuSlideAnimationFactor : 0;
     leftFrame.origin.y = 0;
     [self.leftMenuViewController view].frame = leftFrame;
     [self.leftMenuViewController view].autoresizingMask = UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight;

The reason that this bug does not affect iPhone is because the iPhone Springboard is always shown in portrait mode and thus the app always starts in Portrait mode and then rotates to Landscape mode.

mikefrederick commented 10 years ago

I am closing this, I think it must have been addressed in another commit because I can't replicate it.