OC 集成MMDrawerController,页面会跳动
2021-09-11 本文已影响0人
喵喵粉
pod 'MMDrawerController', '~> 0.6.0'
- 参数传
nil
,会导致两侧的页面跳动。加个空页面传参数。
//加个空页面传参数
NBBBaseNavVC *lNav = [[NBBBaseNavVC alloc] initWithRootViewController:[UIViewController new]];
MMDrawerController *drawerController = [[MMDrawerController alloc]
initWithCenterViewController:naMainView
leftDrawerViewController:lNav
rightDrawerViewController:naRightView];
- 右侧的
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;