IOS---Solve the problem of Residemenu all interfaces

Source: Internet
Author: User

Residemenu is an easy-to-use slide-off Layout class library in iOS, and many iOS projects have this kind of slide-and-swipe effect.

You can add a menu view controllers on both left and right sides of your content view controller.

Basic use

Residemenu is very simple to use, introducing and inheriting Residemenu and its residemenudelegate in startup Rootviewcontroller.
Header file:

// RootViewController.h#import "RESideMenu.h"@interface RootViewController : RESideMenu <RESideMenuDelegate>@end

Then, set the good residemenu in the rootviewcontroller.m file:

//ROOTVIEWCONTROLLER.M#import "RootViewController.h"  @interface rootviewcontroller ()@end @implementation rootviewcontroller - (void) Viewdidload {[SuperViewdidload];} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];} - (void) awakefromnib { Self. Menupreferredstatusbarstyle= Uistatusbarstylelightcontent; Self. Contentviewshadowcolor= [UicolorBlackcolor]; Self. Contentviewshadowoffset= Cgsizemake (0,0); Self. Contentviewshadowopacity=0.6; Self. Contentviewshadowradius= A; Self. contentviewshadowenabled=NO; Self. Contentviewcontroller= [ Self. Storyboardinstantiateviewcontrollerwithidentifier:@"Contentviewcontroller"]; Self. Leftmenuviewcontroller= [ Self. Storyboardinstantiateviewcontrollerwithidentifier:@"Leftmenuviewcontroller"]; Self. Delegate= Self;}#pragma mark-residemenu Delegate- (void) Sidemenu: (Residemenu *) Sidemenu Willshowmenuviewcontroller: (Uiviewcontroller*) Menuviewcontroller {}-(void) Sidemenu: (Residemenu *) Sidemenu Didshowmenuviewcontroller: (Uiviewcontroller*) Menuviewcontroller {}-(void) Sidemenu: (Residemenu *) Sidemenu Willhidemenuviewcontroller: (Uiviewcontroller*) Menuviewcontroller {}-(void) Sidemenu: (Residemenu *) Sidemenu Didhidemenuviewcontroller: (Uiviewcontroller*) Menuviewcontroller {}@end

Note the Awakefromnib method, which sets the Residemenu
Contentviewcontroller and Leftmenuviewcontroller, the viewcontroller here are loaded by storyboard.
Here, Residemenu can be used freely in the project.

Problems brought about by

However, during the use of Residemenu, it was found that by default all interfaces were added to the slide-by feature. such as: Our navigation menu can be placed on the left and right side of the screen, slide to display it. However, when we go into a secondary view, or even a deeper layer of view, the slide-by feature is still available. This is in conflict with Uinavigationcontroller:
1. The left slide operation is expected to return to the top-level view of the Uinavigationcontroller, but becomes the left menu.
2. In some editing text, such as the view, the left slide also shows the left menu, the edited text content cannot be saved.

For the above problem 2, use the following method to suppress the Navigationcontroller left slide effect:

self.navigationController.interactivePopGestureRecognizer.enabled = YES;  self.navigationController.interactivePopGestureRecognizer.delegate = nil;

However, Residemenu's left-slip effect is not prohibited.

Workaround

The above is the situation I encountered in the project, do not know whether the use of the wrong posture?
Here's the solution:
The Residemenu class has a bool attribute pangestureenabled, which can be viewed as a slide-slip effect switch.
Then we can solve the above problem by controlling this property. Here's how to use notifications:
is still in the. m file,

//ROOTVIEWCONTROLLER.M- (void) Viewdidload {[SuperViewdidload]; [[NsnotificationcenterDefaultcenter] Addobserver: SelfSelector@selector(Disableresidemenu) name:@"Disableresidemenu"ObjectNil]; [[NsnotificationcenterDefaultcenter] Addobserver: SelfSelector@selector(Enableresidemenu) name:@"Enableresidemenu"ObjectNil];} - (void) Enableresidemenu { Self. pangestureenabled=YES;} - (void) Disableresidemenu { Self. pangestureenabled=NO;}

Call the following code when you need to prohibit side-slip:

// 关闭侧滑效果[[NSNotificationCenter defaultCenter] postNotificationName:@"disableRESideMenu" object:self userInfo:nil];// 开启侧滑效果[[NSNotificationCenter defaultCenter] postNotificationName:@"enableRESideMenu" object:self userInfo:nil];

Interested in a small partner, you can try.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS---Solve the problem of Residemenu all interfaces

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.