1

I am using the SkyFloatingLabelTextField which is a custom UITextField. After Adding the IQKeyboardManager into my Podfile (pod install), it was expected that it will automatically handle the keyboard issue.

Any clue to integrate IQKeyboardManager with customTextfield?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
MANISH PATHAK
  • 2,602
  • 4
  • 27
  • 31
  • did you enabled the iqkeyboard manager for that VC ? – dip Dec 01 '16 at 08:57
  • I haven't used the `SkyFloatingLabelTextField` before, but did you enable the `IQKeyboardManager` yet? – chengsam Dec 01 '16 at 09:15
  • Already enabled the `IQKeyboardManage`r, I am putting `two textfield` in a uiview , iPad Landscape orientation, the `keyboard` is covering the uitextfield on clicking the `first textfield`. is there any way to do for custom uitextfield? – MANISH PATHAK Dec 01 '16 at 10:43

2 Answers2

1

Solution For SWIFT 3.0+

In AppDelegate :

 // Enable IQKeyboardManager for customization
        IQKeyboardManager.sharedManager().enable = true

In UIViewController

class A : UIViewController

viewDidLoad() {
        customizeKeyboard()
    }


func customizeKeyboard(){

    IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true
    IQKeyboardManager.sharedManager().shouldShowTextFieldPlaceholder = false
    IQKeyboardManager.sharedManager().toolbarDoneBarButtonItemText = ""
    IQKeyboardManager.sharedManager().shouldHidePreviousNext = true
    IQKeyboardManager.sharedManager().keyboardDistanceFromTextField = 150

    emailTextField.delegate = self
    passwordTextField.delegate = self

    // to remove the autocorrect on top of keyboard
    emailTextField.autocorrectionType = .no
    emailTextField.keyboardType = .emailAddress

    // to remove the IQManager view on top of Keyboard
    let emptyUIView = UIView()
    emailTextField.inputAccessoryView = emptyUIView
    passwordTextField.inputAccessoryView = emptyUIView
    forgotEmailTextField.inputAccessoryView = emptyUIView
    }
}
MANISH PATHAK
  • 2,602
  • 4
  • 27
  • 31
0

You can set keyboard setting in SceneDelegate.swift, Just add this code...

 // MARK: - IQKeyboard settings
    func setupIQKeyboard()
    {
        //Enabling keyboard manager
        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.keyboardDistanceFromTextField = 15
        
        //Enabling autoToolbar behaviour. If It is set to NO. You have to manually create IQToolbar for keyboard.
        IQKeyboardManager.shared.enableAutoToolbar = true
        IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "Done"
        
        //Setting toolbar behavious to IQAutoToolbarBySubviews. Set it to IQAutoToolbarByTag to manage previous/next according to UITextField's tag property in increasing order.
        IQKeyboardManager.shared.toolbarManageBehaviour = .bySubviews
        
        //Resign textField if touched outside of UITextField/UITextView.
        IQKeyboardManager.shared.shouldResignOnTouchOutside = true;
        
        //Show TextField placeholder texts on autoToolbar
        IQKeyboardManager.shared.shouldShowToolbarPlaceholder = true
        
        IQKeyboardManager.shared.previousNextDisplayMode = .alwaysShow
    }