IdleHandsApps / IHKeyboardAvoiding

IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!
MIT License
1.41k stars 151 forks source link

Avoiding view + keyboard height bigger than screen #27

Closed sagits closed 7 years ago

sagits commented 7 years ago

Hi, i have a UIView with 8 UITextField plus some buttons below. I have managed to make the view i want visible using the:

func textFieldDidBeginEditing(_ textField: UITextField) {

        IHKeyboardAvoiding.setAvoiding(textField.superview!, withTriggerView: textField)
}

Now, when editing a UITextField and clicking on next, it ll automatically scroll to the next. But is there any other way to be able to select the next UITextField (its below the keyboard before i press next), maybe using a scrollview? Thanks in advance.

fraserscottmorrison commented 7 years ago

Ive just done some testing around this, and IHKeyboardAvoiding does handle the situation where a user taps return and a UITextField thats under the keyboard is focused.

Are you changing the first responder in textFieldShouldReturn?

    public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        KeyboardAvoiding.avoidingView = textField.superview!
        return true
    }

    public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        if textField == self.textField1 {
            self.textField2.becomeFirstResponder()
        }
        return true
    }