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 755 forks source link

disable left menu #112

Open ahmedsafadii opened 8 years ago

ahmedsafadii commented 8 years ago

how i can disable left menu in one controller !?

hlandao commented 8 years ago

I created a pull-request just for that.

117

ahmedsafadii commented 8 years ago

i fix it by edit 1 line in UIViewController.swift file

func setNavigationBarItem() { //self.addLeftBarButtonWithImage(UIImage(named: "ic_notifications_black_24dp")!) self.addRightBarButtonWithImage(UIImage(named: "ic_menu_black_24dp")!) self.slideMenuController()?.removeLeftGestures() self.slideMenuController()?.removeRightGestures() self.slideMenuController()?.addLeftGestures() self.slideMenuController()?.addRightGestures() }

hlandao commented 8 years ago

@ahmedsafadii yours is a better solution

ahmedsafadii commented 8 years ago

@hlandao if you want to load the left or right menu in custom controller i can help u with that

;)

pbassut commented 8 years ago

Why this can't be done? I wanted to enable the right menu just when the user is logged in.

In that case, I think a solution should be provided in the README since this is a trivial case. Or this PR accepted.

ahmedsafadii commented 8 years ago

@pbassut did it work for you ?

pbassut commented 8 years ago

It did. I'm not sure if removing and adding gesturerecognisers is a hackish way though.

Let's wait for the author. And thank you for your help, @ahmedsafadii .

leizard commented 8 years ago

@pbassut , I need to implement the same use case. I'm not clear how you did that. How did you disable the right side menu and enable it again ?

pbassut commented 8 years ago

@leizard just call self.slideMenuController()?.removeLeftGestures()

ahmedsafadii commented 8 years ago

@leizard as @pbassut said in the file

UIViewController.swift

comment this line

//self.addLeftBarButtonWithImage(UIImage(named: "ic_notifications_black_24dp")!)

leizard commented 8 years ago

Thanh you @pbassut, @ahmedsafadii for your support. So, call removeLeftGestures() to disable right menu ? It seem not work to me, this is my slide menu set up method put in AppDelegate.swift

    func setUpSideMenu() {
        let screenWidth = UIScreen.mainScreen().bounds.size.width
        SlideMenuOptions.hideStatusBar = false
        SlideMenuOptions.leftViewWidth = (80*screenWidth)/100
        SlideMenuOptions.rightViewWidth = (80*screenWidth)/100
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let mainViewController = storyboard.instantiateViewControllerWithIdentifier("mainNavigationViewController")
        let leftViewController = storyboard.instantiateViewControllerWithIdentifier("LeftMenuController") as! LeftMenuController
        let rightViewController = storyboard.instantiateViewControllerWithIdentifier("RightMenuController") as! RightMenuController
        let slideMenuController = SlideMenuController(mainViewController: mainViewController, leftMenuViewController: leftViewController, rightMenuViewController: rightViewController)
        slideMenuController.removeLeftGestures()
        self.window?.rootViewController = slideMenuController
        self.window?.makeKeyAndVisible()
    }

Everything works fine instead slideMenuController.removeLeftGestures() not disable anything. Please tell me where I'm wrong. Thank you very much.

leizard commented 8 years ago

Ok I did it. just call self.slideMenuController()?.removeRightGestures() in each view controller which have right slide menu. I think it will be awesome if we can enable/disable slide menu globally :D. Thank you guys very much for your information.