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
Related
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
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.
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;
Have ViewController with SearchBar.
After click search button appears SearchBar with focus
How to hide 2 segmented controls "Title"?
Alternate to Jeff's answer
If this code segmentedControl.hidden = YES; is not working.. Then Embed the segment control inside UIView and hide that view like this,
view.hidden = YES;
You need to hide the UISegmentedControl, as a UIView subclass it has a hidden property.
segmentedControl.hidden = YES;
I am adding Swift 3 solution so that it will be useful for others. In Swift 3, you can hide UISegmentedControl like this
segmentedControl.isHidden = true
I want to use a search bar button in a navigation bar to show a search bar just like Apple do in the Calendar app. The cancel button would dismiss the search bar and return the navigation bar to its former state, bar buttons, title, etc.
Using the iOS 7 property:
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
puts the search bar into the navigation bar just fine. My problem is trying to have it appear conditionally on the press of a bar button. I've tried firing this line from my button's action but no go. I've tried setActive:Animated: on the searchDisplayController
self.searchDisplayController.active = YES;
but no luck either. Any ideas or help would be appreciated.
I'm not sure if you notice, but on the Apple's calendar app when you press the search icon, it open a new UITableView with search bar. If this is what you want to do, you will have a create a UIViewController with a UITableView and a UISearchBar which inside that tableView you will be filtering the content.
If I was you, I will just hide the UISearchBar and call it whenever is needed with the button to show up.
This might work as well. Just give it a try and let me know:
In your viewWillAppear:
- (void)viewWillAppear:(BOOL)animated {
// scroll search bar out of sight
CGRect newBounds = self.tableView.bounds;
if (self.tableView.bounds.origin.y < 44) {
newBounds.origin.y = newBounds.origin.y + self.searchBar.bounds.size.height;
self.tableView.bounds = newBounds;
}
// new for iOS 7
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:0 animated:YES];}
Now that is hidden, call this to hide it again when the search is done:
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[self viewWillAppear:YES];
}
and to show the searchBar with a button, then:
- (IBAction)displaySearchBar:(id)sender {
// makes the search bar visible
[self.searchBar becomeFirstResponder];
}
In iOS 8 you can simply present a UISearchController and you will get the same animation as Calendar.app. Check out Apple's UICatalog sample code for an example.