For iOS, MMDrawerController and mmdrawercontroller are developed to solve the gesture conflict between the left and right drawer open gesture and the center view sub-View Controller.

Source: Internet
Author: User

For iOS, MMDrawerController and mmdrawercontroller are developed to solve the gesture conflict between the left and right drawer open gesture and the center view sub-View Controller.

MMDrawerController is a very useful third-party class to implement drawer effects. However, when we use gestures to perform other operations in the subview controller of the central view, a gesture conflict occurs, as a result, the running effect does not conform to our imagination. Now, how can we solve the conflict?

The following is my personal summary during use:

My requirements:

1. Only the left drawer and the center View Controller are available. Right-sliding sub-view controllers in the center view can open the left drawer.

2. TableViewCell in the subview controller of the central view can be deleted by sliding gesture

 

Problem:

1. Because the left slide gesture of deleting cell conflicts with the left slide gesture of opening the right drawer of MMDrawerController (although I have not set the right drawer ), as a result, the cell deletion method (of course, the system method) on the left slides and sometimes does not respond.

 

Expected results:

1. Remove the cell deletion gesture conflict.

2. Slide right to open the left drawer

 

Thinking process:

1. The drawer effect is similar to that of mobile QQ. When we want to open the left drawer of mobile QQ via a sliding gesture, we need to slide to the right of the left border with our fingers, sliding from the center to the right does not produce the effect of opening the left drawer.

However, MMDrawerController can open the left drawer by right slide from any position of the central View Controller by default (note the difference between the two)

2. There should be a gesture recognition method in MMDrawerController. The problem can be solved by finding this method.

 

Solution Process:

1. Search for GestureRecognizer through command + F in each. m file in the MMDrawerController folder, and find it in the class MMDrawerController.

-(MMOpenDrawerGestureMode) possibleOpenGestureModesForGestureRecognizer :( UIGestureRecognizer *) gestureRecognizer withTouch :( UITouch *) touch; this method

2. PointContainedWithinCenterViewContentRect is found in this method: This judgment condition is found. Press and hold the command button to jump to its location. The problem is found here. The solution is as follows:

 

1460 rows in MMDrawerController. m

-(BOOL) isPointContainedWithinCenterViewContentRect :( CGPoint) point {

// CGRect centerViewContentRect = self. centerContainerView. frame; // The original text indicates that gesture recognition of the trigger drawer is placed throughout the screen.

CGRect centerViewContentRect = CGRectMake (0, 0, 50, self. centerContainerView. frame. size. height); // after modification, it means to place the trigger opening drawer Gesture Recognition in the rect with the height of the screen 50 in width on the left side of the screen.

CenterViewContentRect = CGRectIntersection (centerViewContentRect, self. childControllerContainerView. bounds );

Return (CGRectContainsPoint (centerViewContentRect, point )&&

[Self isPointContainedWithinNavigationRect: point] = NO );

}

 

Because I did not take the right drawer for testing, the code comments are also based on my understanding, and may be somewhat inappropriate, however, it is easy to solve the conflict between the left-right drawer gesture and the center view sub-View Controller gesture by using the above method.

 

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.