Mmdrawercontroller use of problems and customization

Source: Internet
Author: User

Mmdrawercontroller

1,
Integration
Rightdrawerviewcontroller:rightdrawer];

Detailed code

TABVC = [[Tabbarcontroller alloc]init];

Left page frame

Leftpage *leftcontroller = [[Leftpage alloc] init];

Self.drawercontroller = [[Mmdrawercontroller alloc]

Initwithcenterviewcontroller:tabvc

Leftdrawerviewcontroller:leftcontroller

Rightdrawerviewcontroller:nil];

[Self.drawercontroller Setshowsshadow:no];

[Self.drawercontroller setrestorationidentifier:@ "Mmdrawer"];

[Self.drawercontroller setmaximumleftdrawerwidth:260.0];

Self.drawerController.visibleLeftDrawerWidth = 260;

[Self.drawercontroller Setopendrawergesturemodemask:mmopendrawergesturemodeall];

[Self.drawercontroller Setclosedrawergesturemodemask:mmclosedrawergesturemodeall];

Slip-on launch style

[[Mmexampledrawervisualstatemanager Sharedmanager] setleftdraweranimationtype:1];

[Self.drawercontroller

setdrawervisualstateblock:^ (Mmdrawercontroller *drawercontroller, Mmdrawerside drawerside, CGFloat percentVisible) {

Mmdrawercontrollerdrawervisualstateblock Block;

block = [[Mmexampledrawervisualstatemanager Sharedmanager]

Drawervisualstateblockfordrawerside:drawerside];

if (block) {

Block (Drawercontroller, drawerside, percentvisible);

}

}];

[Self.window SetRootViewController:self.drawerController];


Redefining the top left button event in the main interface

-(void) leftbtnpressed

{

[[(Appdelegate *) [[uiapplication Sharedapplication] delegate] Menucontroller] Showleftcontroller:yes];

[Self.mm_drawercontroller toggledrawerside:mmdrawersideleft Animated:yes Completion:nil];

}

When you click on the left Avatar to return to the main interface, you want to go back to the main screen, the demo is re-created a new one that is not available in the project.


2, when the main interface into the level two page, want to remove the gesture. Achieve customization.
In

MMDrawerController.h add

/* 2016-5-10 MXT Add

Open gesture swipe out menu */

@property (assign,nonatomic) BOOL needswipeshowmenu;//whether to open gesture swipe out menu

MMDRAWERCONTROLLER.M add

#pragma mark-helpers

-(void) setupgesturerecognizers{

Pan = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (Pangesturecallback:)];

[Pan setdelegate:self];

[Self.view Addgesturerecognizer:pan];

Tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Tapgesturecallback:)];

[Tap setdelegate:self];

[Self.view Addgesturerecognizer:tap];

}

Rewrite sett

-(void) Setneedswipeshowmenu: (BOOL) needswipeshowmenu{

_needswipeshowmenu = Needswipeshowmenu;

if (Needswipeshowmenu) {

NSLog (@ "--------Needswipeshowmenu----------------------------------yes");

[Self.view Addgesturerecognizer:pan];

}else{

NSLog (@ "--------needswipeshowmenu----------------------------------No");

[Self.view Removegesturerecognizer:pan];

}

}

Add on the page you use

-(void) Viewdidappear: (BOOL) animated

{

[Super viewdidappear:animated];

NSLog (@ "Mine viewdidappear yes");

KAPPDelegate.drawerController.needSwipeShowMenu = YES;

}

-(void) Viewwilldisappear: (BOOL) animated

{

KAPPDelegate.drawerController.needSwipeShowMenu = NO;

}








Mmdrawercontroller use of problems and customization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.