Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard Hides when sidemenu appears but after closing side menu keyboard appears again. #570

Open
5 tasks done
Piyush-Sharma-Pandit opened this issue Oct 21, 2019 · 16 comments

Comments

@Piyush-Sharma-Pandit
Copy link

Piyush-Sharma-Pandit commented Oct 21, 2019

I have read the guidelines for contributing and I understand

  • My issue is happening in the latest version of SideMenu (older versions are no longer maintained).
  • My issue was not solved in the README.
  • My issue can not be answered on stackoverflow.com.
  • My issue is not a request for new functionality that I am unwilling to build and contribute with a pull request.
  • My issue is reproducible in the demo project.

Describe the bug
The bug is Keyboard Hides when sidemenu appears but after closing side menu keyboard appears again. normally this thing does not cause any problem at all. but the only big problem occurs while going to other view from side menu. more explaination in "To Reproduce".

To Reproduce
Steps to reproduce the behavior:

  1. click on search bar so keyboard will appear.
  2. than go to side menu using screen edge pan gesture.
  3. from there go to another view by clicking any button in side menu.
  4. now on this new view controller you will find a black rectangle at the place of keyboard.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Screenshot 2019-10-21 at 4 02 21 PM
Screenshot 2019-10-21 at 4 02 37 PM
Screenshot 2019-10-21 at 4 02 49 PM

Note:= if i do all this without opening keyboard in starting than it works fine.

Additional context
Add any other context about the problem here.

@rehmanateeq
Copy link

Did you find any solution. I am facing same issue and did not find any solution.

@rehmanateeq
Copy link

@jonkykong is there any solution for this behaviour??

@relisiuol
Copy link

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    textField.endEditing(true)
}

@rehmanateeq
Copy link

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    textField.endEditing(true)
}

It was the very first thing i tried

@Piyush-Sharma-Pandit
Copy link
Author

@rehmanateeq No i have tried many things but cant find any way of doing this. So i have disabled the pan gesture and currently having sidemenu only from tapping the side menu button.
Note:- There are some delegate method of the sidemenu
Screenshot 2019-10-25 at 11 22 31 AM

So logically calling end editing in them should work fine but it is not working.
if someone has the solution of this problem please let me know.

@rtemple6
Copy link

Anyone find an update for this? I am experiencing the same thing :(

@aherpooja
Copy link

aherpooja commented Jan 6, 2020

I was facing the same issue.
Simulator Screen Shot - iPhone 8 - 2020-01-02 at 16 30 30

For me issue occurred when: I clicked textField and then opened new ViewController by selecting another SideMenu option. Then there was black view at bottom.

Below solution worked for me.

self.dismiss(animated: true) { () -> Void in
self.customNavigationController.pushViewController(viewController, animated: true)
}

I found this on one of Issue:
"The problem is the presenting controller of Menu still live although SidMenu go away , so you should make it nil , to do that call self.dismiss(animated: false, completion: nil) method when you want go away from SideMenu."

I was not dismissing my SideMenu while pushing another ViewController. So when I did dismiss SideMenu and on its completion then I pushed my ViewController. It resolved the issue for me.

P.S.: I am using customNavigationController so that it will not push ViewController on SideMenuNavigationController.

@rehmanateeq
Copy link

I was facing the same issue.
Simulator Screen Shot - iPhone 8 - 2020-01-02 at 16 30 30

For me issue occurred when: I clicked textField and then opened new ViewController by selecting another SideMenu option. Then there was black view at bottom.

Below solution worked for me.

self.dismiss(animated: true) { () -> Void in self.customNavigationController.pushViewController(viewController, animated: true) }

I found this on one of Issue:
"The problem is the presenting controller of Menu still live although SidMenu go away , so you should make it nil , to do that call self.dismiss(animated: false, completion: nil) method when you want go away from SideMenu."

I was not dismissing my SideMenu while pushing another ViewController. So when I did dismiss SideMenu and on its completion then I pushed my ViewController. It resolved the issue for me.

P.S.: I am using customNavigationController so that it will not push ViewController on SideMenuNavigationController.

This Fixed my issue. Thanks

@rehmanateeq
Copy link

Anyone find an update for this? I am experiencing the same thing :(

Just dismiss Side Menu before pushing/showing another controller

@Piyush-Sharma-Pandit
Copy link
Author

@aherpooja can you please provide a proper example with original code .

@aherpooja
Copy link

@Piyush-Sharma-Pandit When you select any menu option from Side menu before pushing/presenting another view controller first dismiss Side menu.

self.dismiss(animated: true) { () -> Void in
self.customNavigationController.pushViewController(viewController, animated: true)
}

@soztemir
Copy link

soztemir commented Apr 30, 2020

@aherpooja How did you create the sample customNavigationController? Can you share please?

@phoney
Copy link

phoney commented Jul 29, 2020

I also ran into this problem. It appears that UIKit tries to remember if the keyboard is visible when a view controller is shown over another view controller and then closes the keyboard. When the front view controller goes away it restores the keyboard if it was showing. To avoid this problem you have to close the keyboard before showing the side menu. Once the side menu starts to become visible it's too late to prevent UIKit from this process of saving and restoring the keyboard state. I worked around this by closing the keyboard from a custom back button before showing the side menu. This code uses some other methods of mine but you get the idea.

    private func setupNavigationItem() {
        navigationItem.leftBarButtonItem = UIBarButtonItem.buttonWithBurgerMenu(action: #selector(self.openSideMenuSpecial), target: self)
    }
    @objc func openSideMenuSpecial() {
        // resignFirstResponder before opening the sideMenu
        // Otherwise there are crazy animations with the keyboard
        resignFirstResponderTextFields()
        openSideMenu()
    }

There is some code in SideMenuNavigationController that attempts to avoid this problem but in my case that code was too late. Any of the viewWillAppear, viewDidAppear or SideMenu delegate callbacks were also too late and resulted in the keyboard going away but it still came back with some crazy animations.

@jonkykong
Copy link
Owner

@phoney feel free to propose a more robust solution directly to the source code that alleviates this issue.

@kishorekankata
Copy link

Any update

@FarhanBykea
Copy link

FarhanBykea commented Oct 13, 2020

Any update

@objc func openMenu() { self.view.endEditing(true) let leftRootVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "LeftMenuViewController") let leftMenuNavigationController = SideMenuNavigationController(rootViewController: leftRootVC) leftMenuNavigationController.leftSide = true self.present(leftMenuNavigationController, animated: true, completion: nil) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants