IOS --- solve the problem that all interfaces in RESideMenu can slide sideways

Source: Internet
Author: User

IOS --- solve the problem that all interfaces in RESideMenu can slide sideways

RESideMenu is an easy-to-use slide layout class library in iOS. This type of Slide effect is used in many iOS projects.

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

Basic usage

RESideMenu is easy to use. It introduces and inherits RESideMenu and its RESideMenuDelegate in the startup RootViewController.
Header file:

// RootViewController.h#import RESideMenu.h@interface RootViewController : RESideMenu 
  
   @end
  

Then, set the RESideMenu in the RootViewController. m file:

//  RootViewController.m#import RootViewController.h@interface RootViewController ()@end@implementation RootViewController- (void)viewDidLoad {  [super viewDidLoad];}- (void)didReceiveMemoryWarning {  [super didReceiveMemoryWarning];}- (void)awakeFromNib {  self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent;  self.contentViewShadowColor = [UIColor blackColor];  self.contentViewShadowOffset = CGSizeMake(0, 0);  self.contentViewShadowOpacity = 0.6;  self.contentViewShadowRadius = 12;  self.contentViewShadowEnabled = NO;  self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@ContentViewController];  self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@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 that the awakeFromNib method sets the RESideMenu
ContentViewController and leftMenuViewController, where ViewController is loaded through storyboard.
At this point, RESideMenu can be freely used in the project.

Problems

However, during the use of RESideMenu, it is found that all interfaces are added with the slide function by default. for example, we can place the navigation Menu on the left and right sides of the screen, and slide it to display it. however, when we enter a secondary View or even a deeper View, the slide function is still available. this conflicts with UINavigationController:
1. The left slide operation is expected to return the previous View of UINavigationController, but it is changed to the left Menu.
2. In some views such as editing text, the left Menu is displayed as sliding left, And the edited text content cannot be saved.

For question 2 above, use the following method to disable the left slide Effect of navigationController:

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

However, the left slide Effect of RESideMenu is not prohibited.

Solution

The above is what I encountered in the project. I don't know if it is correct?
Solutions:
The RESideMenu class has a BOOL attribute panGestureEnabled, which can be regarded as a toggle.
We can solve the above problem by controlling this attribute. Here we use the notification method:
Still in the. m file,

// RootViewController.m- (void)viewDidLoad {  [super viewDidLoad];  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disableRESideMenu) name:@disableRESideMenu object:nil];  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enableRESideMenu) name:@enableRESideMenu object:nil];}- (void)enableRESideMenu {  self.panGestureEnabled = YES;}- (void)disableRESideMenu {  self.panGestureEnabled = NO;}

Call the following code to disable slide:

// Disable the sliding effect [[NSNotificationCenter defacenter center] postNotificationName: @ disableRESideMenu object: self userInfo: nil]; // enable the sliding effect [[nsicationicationcenter defacenter center] posticationicationname: @ enableRESideMenu object: self userInfo: nil];

If you are interested, try it.

 

Related Article

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.