美文网首页
OC 集成MMDrawerController,页面会跳动

OC 集成MMDrawerController,页面会跳动

作者: 喵喵粉 | 来源:发表于2021-09-11 16:22 被阅读0次

    pod 'MMDrawerController', '~> 0.6.0'

    1. 参数传nil,会导致两侧的页面跳动。加个空页面传参数。
    //加个空页面传参数
    NBBBaseNavVC *lNav = [[NBBBaseNavVC alloc] initWithRootViewController:[UIViewController new]];
    
    MMDrawerController *drawerController = [[MMDrawerController alloc]
                                                initWithCenterViewController:naMainView
                                                leftDrawerViewController:lNav
                                                rightDrawerViewController:naRightView];
    
    1. 右侧的vc显示,往右边拖动的时候会显示左边的空页面的问题。
      有2种解决方式:
    • 设置左边空页面的宽度
      设置左边页面宽度>0的数即可,比如0.01
    CGFloat width = kIsIpad ? kScreenWidth*0.3 : kScreenWidth*0.5;
    //往右边拖动会把左边的vc显示出来,这里设置左边的view宽度0.1就基本看不见
    drawerController.maximumLeftDrawerWidth = 0.01;
    drawerController.maximumRightDrawerWidth = width;
    
    • 设置关闭2边页面的方式

    关闭页面有以下几种Mode

    typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) {
        MMCloseDrawerGestureModeNone                    = 0,
        MMCloseDrawerGestureModePanningNavigationBar    = 1 << 1,
        MMCloseDrawerGestureModePanningCenterView       = 1 << 2,
        MMCloseDrawerGestureModeBezelPanningCenterView  = 1 << 3,
        MMCloseDrawerGestureModeTapNavigationBar        = 1 << 4,
        MMCloseDrawerGestureModeTapCenterView           = 1 << 5,
        MMCloseDrawerGestureModePanningDrawerView       = 1 << 6,
        MMCloseDrawerGestureModeCustom                  = 1 << 7,
        MMCloseDrawerGestureModeAll                     =   MMCloseDrawerGestureModePanningNavigationBar    |
                                                            MMCloseDrawerGestureModePanningCenterView       |
                                                            MMCloseDrawerGestureModeBezelPanningCenterView  |
                                                            MMCloseDrawerGestureModeTapNavigationBar        |
                                                            MMCloseDrawerGestureModeTapCenterView           |
                                                            MMCloseDrawerGestureModePanningDrawerView       |
                                                            MMCloseDrawerGestureModeCustom,
    };
    

    现在只需要点击关闭页面的Mode

    //drawerController.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
        
    //或者不让拖动只点击才能关闭2边的vc,就不会将左边的vc拖出来
    MMCloseDrawerGestureMode mode = MMCloseDrawerGestureModeTapNavigationBar | MMCloseDrawerGestureModeTapCenterView;
    drawerController.closeDrawerGestureModeMask = mode;
    

    相关文章

      网友评论

          本文标题:OC 集成MMDrawerController,页面会跳动

          本文链接:https://www.haomeiwen.com/subject/yukawltx.html