0

MMdrawerController用来在我的项目中练习侧抽屉控制器。但是当我点击左侧的菜单按钮,然后点击选择的行时,它打开得很好,但是相应的视图没有在视图的左侧显示菜单项(抽屉菜单按钮)。所以我无法做出任何进一步的选择。我使用故事板。

MydrawerController 我在抽屉的表格视图中浏览单元格的示例代码。

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.delegate drawerMenuViewController:self didSelectMenuSection:indexPath.row];
       switch ((MMDrawerMenuViewControllerSection)indexPath.row) {
        case MMDrawerMenuViewControllerSectionProfile:

            [self.mm_drawerController setCenterViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"MMProfileViewController"] withCloseAnimation:YES completion:nil];


            break;

        default:
            break;
    }


}

我的中心观点只是做这些:

-(void)setupLeftMenuButton{
    MMDrawerBarButtonItem *leftDrawerButton=[[MMDrawerBarButtonItem alloc]initWithTarget:self action:@selector(leftDrawerButtonPress:)];
    [self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];


}


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

-(void)leftDrawerButtonPress:(id)sender{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

-(void)doubleTap:(UITapGestureRecognizer*)gesture{
    [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil];
}

我的另一个无法显示菜单项的视图控制器具有上面给出的相同按钮处理程序。但仍然没有显示菜单项。

4

1 回答 1

-1

无法从侧视图将控制器推入 centerView,我已经这样做了但需要使用委托,我已经在左侧控制器中定义了一个协议,例如

@protocol LGSettingDrawerControllerDelegate <NSObject>

- (void)pushControllerWithIndex:(NSIndexPath*)indexPath;

@end

@property (nonatomic, weak) id<LGSettingDrawerControllerDelegate> delegate;

并且在

.m 文件

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (_delegate != nil) {
        [_delegate pushControllerWithIndex:indexPath];
    }
    [self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
}

并且这个委托方法确实推送到中心视图控制器,如

[self.mm_drawerController setCenterViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"MMProfileViewController"] withCloseAnimation:YES completion:nil];
于 2014-07-10T14:43:41.550 回答