Open michaelbanholzer opened 10 years ago
+1, the panGestureRecognizer
getter is even misleading because I'd expect it to return the currently attached recognizer.
@michaelbanholzer @keeshux I agree that it is misleading to return a new gesture recognizer every time that panGestureRecognizer
is called. The reason I did this at the time was that the library needed a way to add the pan gesture to any custom view, and you can only add an instance of a UIGestureRecognizer to one view. So each view that you add the pan gesture to needs it's own instance of the UIPanGestureRecognizer. If panGestureRecognizer
was a class method instead of an instance method it might be more straightforward.
Instance method is the right choice here, just give it a different name. E.g. use panGestureRecognizer
for the one you attach to your own view and provide something like attachablePanGestureRecognizer
for custom external views.
P.S.: you can internally reuse the attachable method to also create your recognizers, the important bit is: only create yours once, but leave the user a way to create any.
Nice sidemenu, well done! Thanks!
But why do you recreate a new gestureRecognizer every time the methods centerTapGestureRecognizer and panGestureRecognizer in MFSideMenuContainerViewController are called? Maybe you'll overflood the view with gestureRecognizers!
Thus the method removeCenterGestureRecognizers is meaningless, since removeGestureRecognizer: takes the new allocated gestureRecognizer and not the attached recognizer! I.e. you can keep them with instance variables