mutualmobile / MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
MIT License
6.76k stars 1.38k forks source link

First time u click the left button to show the leftViewController #378

Open yuedong56 opened 9 years ago

yuedong56 commented 9 years ago

First time u click the left button to show the leftViewController(not drag the screen),there is a problem that the left view controller will drop down 20 px without animation.

maxgribov commented 9 years ago

This is very annoying...

I fixed it with this kinda spaghetti code :

  1. Turn OFF Adjust Scroll View Insets for TableView of my leftViewController
  2. Add this code in my leftViewController
//  MenuTableViewController.m

@interface MenuTableViewController (){
    BOOL firstTimeOpen;
}
@end

@implementation MenuTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //...
    firstTimeOpen = YES;
}

-(void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

     if (firstTimeOpen) {
        [self.tableView setContentInset:UIEdgeInsetsMake(64.0, 0, 44.0, 0)];
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];

        firstTimeOpen = NO;
    }
}

//...

@end

still waiting for fix ...

yuedong56 commented 9 years ago

@maxgribov thx for your answer.

maxgribov commented 9 years ago

by the way, we can skip this code:

[super viewDidLayoutSubviews];

because original method viewDidLayoutSubviews - do nothing. So it must be:

-(void)viewDidLayoutSubviews {

     if (firstTimeOpen) {
        [self.tableView setContentInset:UIEdgeInsetsMake(64.0, 0, 44.0, 0)];
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];

        firstTimeOpen = NO;
    }
}
jvanlint commented 9 years ago

I am experiencing this as well....and yes...it is annoying. I also have weird jumping behaviour when using the pan gesture. Using the left button bar does it once but the pan gesture misaligns the view each time.