kawoou / KWDrawerController

Drawer view controller that easy to use!
MIT License
157 stars 32 forks source link

I can't trigger to open left or right side by button action. #29

Open GokmenAkar opened 6 years ago

GokmenAkar commented 6 years ago

I followed instructions for storyboard and I set controllers correctly.

class Example: UIViewController, DrawerControllerDelegate {

override func viewDidLoad()  {
        super.viewDidLoad()
        self.drawerController?.delegate = self
        self.drawerController?.options.isAnimation = false
        self.drawerController?.setTransition(DrawerFloatTransition(), for: .left)
}

When I try to trigger open left side with this code block, drawerController throws nil error and crash.

if self.drawerController!.drawerSide == .none {
            self.drawerController?.openSide(.left)
                .subscribe()
                .disposed(by: disposeBag)
        } else {
            self.drawerController?.closeSide()
                .subscribe()
                .disposed(by: disposeBag)
        }
kawoou commented 6 years ago

What version are you using?

GokmenAkar commented 6 years ago

@kawoou Xcode Version: Version 9.3.1 Swift Version: 4.1 Pods:

kawoou commented 6 years ago

What class is calling the code that calls openSide method?

If this ViewController calling the self.drawerController property does not have a DrawerController in its super, it will be nil.

neburzepol commented 5 years ago

I followed instructions for storyboard and I set controllers correctly.

class Example: UIViewController, DrawerControllerDelegate {

override func viewDidLoad()  {
        super.viewDidLoad()
        self.drawerController?.delegate = self
        self.drawerController?.options.isAnimation = false
        self.drawerController?.setTransition(DrawerFloatTransition(), for: .left)
}

When I try to trigger open left side with this code block, drawerController throws nil error and crash.

if self.drawerController!.drawerSide == .none {
            self.drawerController?.openSide(.left)
                .subscribe()
                .disposed(by: disposeBag)
        } else {
            self.drawerController?.closeSide()
                .subscribe()
                .disposed(by: disposeBag)
        }

I have the same problem, could you solve it?

neburzepol commented 5 years ago

I have the same problem, I follow the readme manual but I have the same crash, the self.drawerController is nil, any suggest?

best regards

BeechMachine commented 5 years ago

Also having issues with self.drawerController?.openDrawer(.left) and self.drawerController?.closeDrawer(). In my case, both the left and centre have UINavigationContoller's embedded in them, each with a single UIViewController embedded as the rootViewController. Each has a left bar button item in the Navigation Bar that calls a private function that just calls the open or close. In both cases, the private function is getting called, but the DrawerController isn't responding. I've logged out the self.drawerController, it's not nil. I've also setup my view controller as the DrawerControllerDelegate, none of the delegate methods are getting called. My DrawerController was setup in storyboard, just in case that's relevant.

4bottiglie commented 5 years ago

Just call self.drawerController?.openSide(.left, completion: nil), The completion: nil do the trick.