dekatotoro / SlideMenuControllerSwift

iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
MIT License
3.4k stars 754 forks source link

Bug. After closing menu cannot open menu with gesture #140

Closed Sol88 closed 8 years ago

Sol88 commented 8 years ago

I have left menu in my app and no right menu After first init everything is OK, but after I close menu with this method public func changeMainViewController(mainViewController: UIViewController, close: Bool) I cannot open menu with swipe (only button)

I suppose that reason is the method public func changeMainViewController(mainViewController: UIViewController, close: Bool) in line 642 at that line we are closing right menu although there is no right menu

so in the method public func closeRightWithVelocity(velocity: CGFloat) we change frame of the rightContainerView and after this change method public func isRightOpen() -> Bool will return true cause rightContainerView.frame.size.width == 0 and rightContainerView.frame.origin.x == CGRectGetWidth(view.bounds)

and so method func handleLeftPanGesture(panGesture: UIPanGestureRecognizer) will return at line 327

I offer fix of this issue like this

 public func changeMainViewController(mainViewController: UIViewController,  close: Bool) {

    removeViewController(self.mainViewController)
    self.mainViewController = mainViewController
    setUpViewController(mainContainerView, targetViewController: mainViewController)
    if (close) {
        if leftContainerView.frame.width > 0 {
            closeLeft()
        }
        if rightContainerView.frame.width > 0 {
            closeRight()
        }
    }
}
Pluto-Y commented 8 years ago

@Sol88 Thanks. I have added the guard for the close(or open) the menu.