CosmicMind / Material

A UI/UX framework for creating beautiful applications.
http://cosmicmind.com
MIT License
11.99k stars 1.26k forks source link

Impossible disabling swipe gestures recognizers. (aka removeGestures method is PRIVATE) #458

Closed TNikolai closed 8 years ago

TNikolai commented 8 years ago

The problem caused by enabled gesture recognizers from sideNavigation, I pushed new one viewController on which i have priceRange when i want swipe I cant because gestures was catched by Sidenavigation.

I resolved this on local version setting two methods from private to public

 public func removeGestures() {
    if let v: UIPanGestureRecognizer = panGesture {
        view.removeGestureRecognizer(v)
        panGesture = nil
    }
    if let v: UITapGestureRecognizer = tapGesture {
        view.removeGestureRecognizer(v)
        tapGesture = nil
    }
}

public func prepareGestures() { if nil == panGesture { panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture)) panGesture!.delegate = self view.addGestureRecognizer(panGesture!) }

    if nil == tapGesture {
        tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture))
        tapGesture!.delegate = self
        tapGesture!.cancelsTouchesInView = false
        view.addGestureRecognizer(tapGesture!)
    }
}
daniel-jonathan commented 8 years ago

If you are using the latest version. There are enable properties you can set.

For example

navigationDrawerController?.enabledLeftPanGesture = false

and so forth. Give those a try, and let me know how it goes. Thank you!

TNikolai commented 8 years ago

I use version 1.39 and in this version i have not this property : navigationDrawerController. .

daniel-jonathan commented 8 years ago

Yes currently Material is at version 1.42.7. I believe I added the enable handler in 1.40.*. Personally I would update to the latest. So many fixes have been made.

daniel-jonathan commented 8 years ago

The NavigationDrawerController is the new name for the SideNavigationController.

TNikolai commented 8 years ago

Mhm now i installed new pod version and i see enabledLeftPanGesture.

TNikolai commented 8 years ago

So it solved issue! thx.

daniel-jonathan commented 8 years ago

:) awesome! Thank you

TNikolai commented 8 years ago

Hi danieldahan, my problem was solved particulary, i saw very strange bug in my app when i download app at first launch bug appears, if i press homeButton and again open app leftPanRecognizer not triggers. In both casses i verified code called : unwrappedSideNavigationController.enabledLeftPanGesture = enabled unwrappedSideNavigationController.enabledLeftTapGesture = enabled

daniel-jonathan commented 8 years ago

If you have that code in the viewDidLoad it won't fire because it is not a child of the NavDrawer. Put it in the viewWillAppear or viewDidAppear method. Or possibly you should share your setup code for that area.

TNikolai commented 8 years ago
override func viewDidDisappear(animated: Bool) {
    super.viewDidDisappear(animated)
    LeftMenuWireFrame.enableLeftSideMenu(false)
}
TNikolai commented 8 years ago

class func enableLeftSideMenu(value: Bool) { if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate { appDelegate.appFlow.homeModule.enableLeftSideMenu(value) } }

func enableLeftSideMenu(enabled: Bool) { if let unwrappedSideNavigationController = sideNavigationController { unwrappedSideNavigationController.enabledLeftPanGesture = enabled unwrappedSideNavigationController.enabledLeftTapGesture = enabled } }

TNikolai commented 8 years ago

i call this method in viewDidDisapear and i verified in debuger it all time entered in all if's.

daniel-jonathan commented 8 years ago

I need to see the setup code. How are you adding the view controllers to the NavigationDrawer, also, what are you enabling and disabling the panning for, could the other parts using pan be causing an issue. Also as a tip, you can simplify these lines

unwrappedSideNavigationController.enabledLeftPanGesture = enabled
unwrappedSideNavigationController.enabledLeftTapGesture = enabled

to

unwrappedSideNavigationController.enabledLeftView = enabled
TNikolai commented 8 years ago

I verified and in my initializatiin code i have initializing SideNavigation(root: NavigationController(homeVc), leftMenuController, nil). I think problem in initializing root like navigation controller. All child viewControllers of NavigationController(homeVc) responds to leftPanRecognizer. I need some how on specified childController to disable leftPanGesture.

daniel-jonathan commented 8 years ago

Yes, you could put in the viewWillAppear a disable or enable call.

There is a helper optional property navigationDrawerController?.enableLeftGesture that you can use in any child view controller. This includes deep hierarchal view controllers.

TNikolai commented 8 years ago

pod 'Material', '~> 1.41' And i have only SideNavigationController class, so i have not controller or property named : "navigationDrawerController".

chashmeetsingh commented 8 years ago

@TNikolai update the pod to the latest version!

TNikolai commented 8 years ago

My current version Using Material (1.41.1) pod 'Material', '~> 1.4' which version i need to use ?

chashmeetsingh commented 8 years ago

1.42.7

TNikolai commented 8 years ago

So i updated pods and all works fine, thx a lot.