1

I'm working with ECSlidingViewController. When I load my view, everything displays perfectly. When I slide the menu out for the first time after loading a view, the two tables in my view change their heights. The top table gets an extra (blank) row for some reason, and the bottom table becomes smaller.

As far as I can tell, no code in either MenuViewController.m or the DoubleTable.m that loads the main view runs when I slide the menu out.

I either need to prevent this resizing from occurring or I need to be able to correct it after the unwanted resize takes effect.

Here is my code for attaching the menu under viewDidLoad:

self.view.layer.shadowOpacity = 0.75f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;


if(![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
    self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
}


[self.view addGestureRecognizer:self.slidingViewController.panGesture];

Some information that might prove useful in uncovering the problem:

  1. I have two views with tables, DoubleTable and SingleTable.
  2. SingleTable, surprise surprise, only has one table, whereas DoubleTable has two.
  3. SingleTable does not have the problem I described above.
  4. The tables in DoubleTable are resized programmatically in viewDidAppear. The table in SingleTable is not resized programatically.
  5. Changing the storyboard in DoubleTable does not seem to affect how the tables get resized when I slide the menu out.
  6. Rather, it seems as though the programatic resize is getting undone as though it never happened when I open the slide menu.

Here is how I am resizing tables in DoubleTable.m:

-(void)viewDidAppear:(BOOL)animated{
    CGRect frame = table1.frame;
    CGRect Rect= [[UIScreen mainScreen] bounds];

    frame.size.height = table1.contentSize.height;
    table1.frame = frame;
    int table2Height = Rect.size.height - 150 - table1.frame.size.height;
    table2.frame = CGRectMake(table2.frame.origin.x, table1.frame.origin.y + 30 + table1.frame.size.height, table2.frame.size.width, table2Height);
}

If there is any more code anyone feels I should post, please feel free to ask.

Marcel Marino
  • 962
  • 3
  • 17
  • 34
  • 1
    You probably need to do your layout in more than just viewDidAppear. Perhaps in `layoutSubviews`? If you have auto layout on in storyboard then it will be adding constraints for you which causes it to snap back whenever layout occurs. You could try turning this off as well, but you have to make sure you have no constraints or it turns back on. – Rory McKinnel Feb 24 '15 at 17:30
  • @RoryMcKinnel Thank you, turning off autolayout fixed it completely. Please add your answer below so I can give you credit. – Marcel Marino Feb 24 '15 at 18:05
  • Welcome. Posted as answer. – Rory McKinnel Feb 24 '15 at 18:12

1 Answers1

0

You probably need to do your layout in more than just viewDidAppear. Perhaps in layoutSubviews? If you have auto layout on in storyboard then it will be adding constraints for you which causes it to snap back whenever layout occurs. You could try turning this off as well, but you have to make sure you have no constraints or it turns back on.

Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28