Hiding IOS keyboard suggestion bar appearing above custom keyboard - ios

I am developing a custom keyboard extension app, but apple keyboard native autocorrection and suggestion does not function with my app. The native autocorrection and suggestion bar is empty and appears persistently above my custom keyboard. I am trying to hide it to create my own with my suggestion list.
The problem is I did not find the way to hide the native suggestion bar.
UITextInputAssistantItem *item = [textInput.textInputView inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
does not work because my custom keyboard does not use a textInput. My custom keyboard works with external text input fields like for example Safari search field using self.textDocumentProxy
Also
self.inputAssistantItem.leadingBarButtonGroups = #[];
self.inputAssistantItem.trailingBarButtonGroups = #[];
does not work.
Any help?
Thank you.

Related

How do I hide the suggestion bar on iOS 15?

I have on OpenGL window that is also used for text input when a text element is clicked in our engine
#interface MyGLView : UIView <UIKeyInput, UITextInput, UITextInputTraits>
Whenever this view becomes first responder, it shows the suggestion bar above the keyboard. On many devices, this covers a very large portion of the screen and makes it hard to lay out the UI.
I have read that the following code is supposed to hide this suggestion bar, but nothing I change seems to have any affect
self.autocorrectionType = UITextAutocorrectionTypeNo;
self.inputAssistantItem.leadingBarButtonGroups = #[];
self.inputAssistantItem.trailingBarButtonGroups = #[];
I have tried putting this in the init for the view as well as in becomeFirstResponder method, but both don't seem to matter. What is the proper way to do this?
I think you're missing spellCheckingType!
This works for me:
self.autocorrectionType = UITextAutocorrectionTypeNo;
self.spellCheckingType = UITextSpellCheckingTypeNo;

Programmatically Hide Keyboard Shortcut Bar iOS 13

I am trying to programmatically remove the keyboard shortcut bar that appears at the bottom of an iPad when an external keyboard is connected.
There are plenty of posts and answers with "solutions" to this, but none of them work with the latest iOS. The closest solution was such:
UITextInputAssistantItem* item = [self inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
All this currently does is remove the buttons on the left side of the bar. And this does nothing also:
textField.autocorrectionType = UITextAutocorrectionTypeNo;
How can I "programmatically" remove this bar??
Sorry for using swift code.
You can try my idea:
change autocorrectionType of UITextField from .yes to no.
Get inputAssistantItem and change leadingBarButtonGroups and trailingBarButtonGroups to empty.
Source code example:
tfSearchNameHiragana.autocorrectionType = .no
let shortcut: UITextInputAssistantItem? = tfSearchNameHiragana.inputAssistantItem
shortcut?.leadingBarButtonGroups = []
shortcut?.trailingBarButtonGroups = []
Following the existing answers didn't do the job for me (iPadOS 14.7.1). Instead of hiding the toolbar, I've got an empty (therefore useless) grey bar sitting on top of my onscreen keyboard, hiding valuable screen real estate, especially on an landscape home-buttoned iPad model.
I found out, that additionally to setting the two empty arrays you need to set the inputAccessoryView to nil. Et voilĂ ! The bar above the keyboard completely disappears.
textField.inputAssistantItem.leadingBarButtonGroups = []
textField.inputAssistantItem.trailingBarButtonGroups = []
textField.inputAccessoryView = nil
You may think that setting the view to nil alone does the job, but as it turned out, this works only in combination with setting the empty arrays.
From InterfaceBuilder, change Correction to No:
Or, from source:
item.autocorrectionType = .no

How i hide a top keyboard bar in iOS 9

I'm a beginner ios developer. I'm trying hide "shortcut keyboard bar" on iOS keyboard with unsuccessful.
Bellow is my code:
- (void)textFieldDidBeginEditing:(UITextField*)textField {
UITextInputAssistantItem* item = [textField inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
}
I did hide the assistant bar buttons with setting autocorretionType, but the top bar with action button (ok, done, ...) don't hide.
Can someone help me out?
Tks.
Try this,
YourTextField.autocorrectionType = UITextAutocorrectionTypeNo;
If your project is using IQKeyboardManager, then to get rid of that top bar, you can use IQKeyboardManager.shared().disabledToolbarClasses.add(YourViewController.self)
remove inputAccessoryView from your UITextField
yourTextField.inputAccessoryview = nil

UITextField inputView displays undo, redo, paste buttons

I have created a custom inputView for my UITextField. The view itself looks and functions great, but on the iPad I'm getting undo, redo, and paste buttons above my custom inputView. How do I remove those buttons? They don't have any functionality, but they should be removed.
With Swift 3 and XCode 8 I was able to remove the bar by removing the two button groups on the text field input:
self.textField.inputAssistantItem.leadingBarButtonGroups.removeAll()
self.textField.inputAssistantItem.trailingBarButtonGroups.removeAll()
// hide undo, redo, paste button bar for textfield input view
UITextInputAssistantItem* item = [your_textfield inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
will hide the top bar for input view.
Reference:How to hide the shortcut bar in iOS9
Try removing the inputAccessoryView:
self.textField.inputAccessoryView = nil;

How to disable keyboard when clicking a UITextField in iOS?

I am currently developing a prototype that I want to do user testing on desktop first before loading to iPad.
I am looking for solutions to disable the keyboard after clicking a textfield. That means after clicking a textfield, user is able to enter information from the macbook keyboard directly, and the virtual keyboard that automatically shows up in the simulator will not appear. I have been through a lot of tutorials but they are all dismissing the keyboard after user entry; that is not what I am looking for. How should I hide the keyboard?
Thanks so much!
Use this:
UIView *dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
myTextField.inputView = dummyView; // Hide keyboard, but show blinking cursor
It works for UITextField and UITextView and they need to be set to editable.
What you did Here:
You created a dummy view of width=hight=0, & assigned it as the inputView of your textField.
How It works:
Instead of showing default, keyboard, now, the viewController is showing DummyView as inputView for your UITextField. As DummyView has Width=height=0, You will not see anything on the screen :)
Here is another answer which I found the same hack but with little additional supportive code snippet to hide the blinking cursor too.
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO; // Hides both keyboard and blinking cursor.
}
I needed this to be done for a Quantity text field where I increase/decrease the quantity using a UIStepper view. So I needed the keyboard to be hidden always.
This will set the inputView of your textField to, basically, an empty UIView with no frame.
self.theTextField.inputView = [[UIView alloc] initWithFrame:CGRectZero];

Resources