0

I have many textFields to fill, i use below code to move the VC modally

@objc func addNewRestaurant() {
        let pushController = RestaurantAddController()
        
        pushController.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
        self.present(pushController, animated: true, completion: nil)
       
    }

And below code to move to next line when i press enter

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        if let nextField = view.viewWithTag(textField.tag + 1) as? UITextField {
            textField.resignFirstResponder()
            nextField.becomeFirstResponder()
          
           
        }

But my screen always remains covered with keyboard like below and i do not see what beneath, even if i cancel it when i reactivate the keyboard , once again fields are hidden

enter image description here

UPDATE SOLUTION -

I ended up using IQKeyboardManager, its giving 3 warnings but not able to understand how it was done, not a solution from apple but need to move on with project, this is what i am getting now b, see below, thanks enter image description here

multiverse
  • 425
  • 3
  • 13
  • have you added scrollView ? – Debashish Das Jul 22 '20 at 06:47
  • No i have not added it, i am not using stroyboard, , but the sample i use , does not use any scrollView as well, the textfield just keeps appearing on pressing enter, not in my case though – multiverse Jul 22 '20 at 06:50
  • https://github.com/michaeltyson/TPKeyboardAvoiding I found this quite nice for this purpose. Check it out. – Rishabh Raghunath Jul 22 '20 at 06:54
  • It will be easier for you if you add a scrollView. Then after getting the height of the keyboard, you can adjust the scrollView content inserts. So that the hidden textfields will be shown just above the keyboard, and you can also scroll to other textfield if your keyboard is active. I usually implement that i can show you ! – Debashish Das Jul 22 '20 at 06:57

2 Answers2

0

Put your all the fields under scroll view and use "TPKeyboardAvoidingScrollView" class for better experience

Arjun hastir
  • 476
  • 2
  • 4
  • 13
  • Thanks, i will try, but i was just wondering if there was no other way, i seem to be having to do one thing after another, like extending classes, adding this and that just endlessly to even get some basic function to work in my app, like is there no other way to get such basic function activated ? – multiverse Jul 22 '20 at 06:57
  • Yes, you can manually calculate the keyboard frame and screen height and then accordingly shift your view or field up with the help of constranits. – Arjun hastir Jul 22 '20 at 07:03
0

Here is an answer. Here is an answer Https://stackoverflow.com/q/26070242/13975969

Swift user
  • 26
  • 2