hackiftekhar / IQKeyboardManager

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
MIT License
16.47k stars 2.41k forks source link

Customize Toolbar #953

Closed cs-joao-souza closed 7 years ago

cs-joao-souza commented 7 years ago

I'm using this configurations

IQKeyboardManager.sharedManager().overrideKeyboardAppearance = true IQKeyboardManager.sharedManager().keyboardAppearance = .dark IQKeyboardManager.sharedManager().keyboardDistanceFromTextField = 50 IQKeyboardManager.sharedManager().toolbarDoneBarButtonItemText = "OK" IQKeyboardManager.sharedManager().shouldToolbarUsesTextFieldTintColor = false IQKeyboardManager.sharedManager().toolbarTintColor = .white IQKeyboardManager.sharedManager().enable = true

And this

let previousSelector = #selector(CreditCardDataDataSource.textFieldCardNumberPreviousAction(barButtonItem:)) let nextSelector = #selector(CreditCardDataDataSource.textFieldCardNumberNextAction(barButtonItem:)) let doneSelector = #selector(CreditCardDataDataSource.textFieldCardNumberDoneAction(barButtonItem:)) textField?.addPreviousNextDoneOnKeyboardWithTarget(self, previousAction: previousSelector, nextAction: nextSelector, doneAction: doneSelector) textField?.setEnablePrevious(false, isNextEnabled: true)

And i'm with a problem that my toolbar is not being customized in this ViewController that i use custom actions for previous, next and done.

How can i solve this?

hackiftekhar commented 7 years ago

I'm not sure why it's not working but I believe this code should be enough to add custom actions

cs-joao-souza commented 7 years ago

When you use the method addPreviousNextDoneOnKeyboardWithTarget you create a new IQToolbar and when its done the general configuration isnt used. So i need to add the new actions and intercept after this method using inputAccessoryView and change what i need.

I think that the general configuration must being taken. What do you say?

hackiftekhar commented 7 years ago

You can create your own UIToolbar and add your own bar buttons and add to your toolbar and you can then assign your textfield.inputAccessoryView = toolbar. Hope this will work.