简体   繁体   English

抽屉菜单的实现,如何关闭菜单-iOS

[英]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? 我有一个应用程序,在其中我正在实现一个抽屉菜单,例如Google+,但是当连续选择时无法关闭菜单,我使用调试器进行检查,并且当我将消息发送到CCKFNavDrawer时,属性的值为零或零,该如何解决?

Repository Here 此处的存储库

CCKFNavDrawer.m I have a class with this method also have it in .h file CCKFNavDrawer.m我有一个使用此方法的类,在.h文件中也有

- (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 在DrawerView.m中有此方法

- (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. 在didSelectRowAtIndexPath中,您将分配一个新的CCKFNavDrawer并调用默认的初始化程序,但是您只需立即调用closeNavigatorDrawer。 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 我认为您必须有一个在程序中其他位置创建的抽屉,而不是创建新的抽屉,您应该在行选择方法中引用该抽屉

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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