Whenever keyboard appears in the project , I can find that by adding observer to UIKeyboardWillShowNotification.
But I want to get access to the tool bar that appears on top of the keyboard globally from not from every viewcontroller
Background:
I am using IQKeyboardManager and I am setting buttons on top of the keyboard using it.
IQKeyboardManager doesn't make the tool bar available for external access.
So I'm wondering if there's any way to get access to the keyboard whenever it appears and iterate the items of toolbar that's on top of the keyboard.
Any tips are welcome
Update:
The problem comes from the source code in the POD.
IQUIView+IQKeyboardToolbar.m
{
//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];
//Title button
toolbar.titleBarButton.title = titleText;
if (@available(iOS 11.0, *)) {}
else
{
toolbar.titleBarButton.customView.frame = CGRectZero;
}
[items addObject:toolbar.titleBarButton];
//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];
}
Because of the above code in their pod
even though there's no title text in tool bar , it's still being added as an item on the toolbar and so when we turn on the accessibility the empty title button is read as Dimmed button.
I have the fix
if(titleText){
//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];
//Title button
toolbar.titleBarButton.title = titleText;
if (@available(iOS 11.0, *)) {}
else
{
toolbar.titleBarButton.customView.frame = CGRectZero;
}
[items addObject:toolbar.titleBarButton];
//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];
}else{
[items addObject:[[self class] flexibleBarButtonItem]];
[items addObject:[[self class] flexibleBarButtonItem]];
[items addObject:[[self class] flexibleBarButtonItem]];
}
But we can't fix their pod from our side.
So I'm wondering if I could get access of the the tool bar above keyboard , then I can effectively remove the empty item and add the items back into the tool bar again and this would fix my problem.
inputAccessoryView?IQKeyboardManager. If you are already setting those buttons, why do you need to get access to those buttons when the keyboard appears?IQKeyboardManager.shared.textFieldView.keyboardToolbarto access the accessory views. You'll probably need to unwrap some optional values in there. It's nice that you can just look at the IQKeyboardManager code (some of it here: github.com/hackiftekhar/IQKeyboardManager/blob/master/…).