iOS development Mmdrawercontroller left and right drawer open gestures solutions for conflict issues with central view sub-view controller gestures

Source: Internet
Author: User

Mmdrawercontroller is a very useful third-party class for solving drawer effects, but sometimes when we need to use gestures to do other things in the central view controller, there is a gesture conflict, which results in a running effect that doesn't fit our imagination. So the question is, how do we solve the problem of conflict?

Here is my personal summary of the use process:

My needs:

1, there is a left drawer and center view controller, from the Center view Controller right slide can open the left drawer.

2. Tableviewcell in the Center view controller can be removed by swiping gestures

The problem lies in:

1, due to the deletion of the cell's left slip gesture and mmdrawercontroller open right drawer of the left slip gesture conflict (although I did not set the right drawer), causing the left slide to delete the cell's method (of course, the system method) sometimes respond sometimes not corresponding.

Solution Purpose:

1. Remove the cell from the gesture conflict

2, right slide can open the left drawer

Thinking Process:

1, this drawer effect is similar to the mobile phone QQ, when we want to open the mobile phone QQ drawer by swiping gesture to the left hand side of the box to swipe to the right, but from the right to the left without creating the effect of open drawer.

However, Mmdrawercontroller can open the left drawer by default from anywhere in the Center View Controller (note the difference between the two)

2, Mmdrawercontroller should have a method to identify the gesture, as long as the problem can be found to solve this method.

Resolution process:

1, in the Mmdrawercontroller of the various files through Command+f search Gesturerecognizer, and finally found in Mmdrawercontroller this class

-(Mmopendrawergesturemode) Possibleopengesturemodesforgesturerecognizer: (uigesturerecognizer*) GestureRecognizer Withtouch: (uitouch*) touch; this method

2, in this method found Spointcontainedwithincenterviewcontentrect: This judgment condition, hold command Click to jump to its location, here to find the problem. The solution is as follows:

MMDRAWERCONTROLLER.M in 1460 rows

Resolve gesture Conflicts

-(BOOL) Ispointcontainedwithincenterviewcontentrect: (cgpoint) point{

CGRect centerviewcontentrect = self.centerContainerView.frame; The original meaning is to place the gesture recognition of the trigger drawer on the entire screen.

CGRect centerviewcontentrect = CGRectMake (0, 0, self.centerContainerView.frame.size.height); The modified meaning is to put the trigger open drawer gesture recognition on the left side of the screen width 50, high for the screen height of the rect

Centerviewcontentrect = Cgrectintersection (centerviewcontentrect,self.childcontrollercontainerview.bounds);

Return (Cgrectcontainspoint (Centerviewcontentrect, point) &&

[self ispointcontainedwithinnavigationrect:point] = = NO);

}

Since there is no test on the right drawer, the code comment is also understood by the individual, which may be inappropriate, but it should be a breeze to resolve the conflict between the left-and center-drawer gestures and the central View sub-view controller gesture in the above way.

iOS Development Mmdrawercontroller solution for the left and right drawer open gesture conflict with central view sub-view controller gestures

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.