简体   繁体   中英

Drawer Menu implementation, how to close menu - IOS

I have an app, where i'm implementing a Drawer Menu, like Google+ but not can close the menu when did select in a row, I check this with debugger and when i send the message to CCKFNavDrawer the values of the propertys are zero or nil, how can solve this?

Repository Here

CCKFNavDrawer.m I have a class with this method also have it in .h file

- (void)closeNavigationDrawer{

//    NSLog(@"close x=%f",self.menuView.center.x);
float duration = MENU_DURATION/self.menuWidth*abs(self.drawerView.center.x)+MENU_DURATION/2; // y=mx+c

// shawdow
[UIView animateWithDuration:duration
                      delay:0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     self.shawdowView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0f];
                 }
                 completion:^(BOOL finished){
                     self.shawdowView.hidden = YES;
                 }];

// drawer
[UIView animateWithDuration:duration
                      delay:0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     self.drawerView.frame = self.outFrame;
                 }
                 completion:nil];
self.isOpen= NO;
}

In the DrawerView.m have this method

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

   CCKFNavDrawer *c = [[CCKFNavDrawer alloc] init];
    [c closeNavigationDrawer];
}

In your didSelectRowAtIndexPath you are allocating a new CCKFNavDrawer and calling the default initialiser but then you just call closeNavigatorDrawer straight away. Your drawer has never been added to a view.

Rather than creating a new drawer I think you must have a drawer you have created somewhere else in your program that you should be referencing in the row select method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM