Removing "bar" above the iphone keyboard - ios

In an iPhone app, when the user clicks a UITextField, this keyboard is displayed. I would like to remove the bar/area containg "<", ">" and "Done".
Any suggestions how to do that?
SOLVED
It turned out that it was IQKeyboardManager that was adding the bar on top of the keyboard.
It was removed by this line in AppDelegate file:
IQKeyboardManager.sharedManager().enableAutoToolbar = false

try :
self.<yourTextField/View>.inputAccessoryView?.hidden = true

Related

How to add a custom button between UISearch Bar and Cancel Button while a search is enabled in Swift?

I'm using ios 14 SDK for development and I want to add a custom button between UISearchBar and the Cancel button when the search is enabled.
I have checked all attributes in UISearchController and UISearchBar level, but i couldn't find any attribute for doing it. :(
I saw a similar kind of button in the default ios files view, I have attached the screenshot and marked it with a red color box.
Can someone give a clue for doing that? I really appreciate your help.
You can try this:
if searchController.isActive {
searchController.searchBar.showsBookmarkButton = true
} else {
searchController.searchBar.showsBookmarkButton = false
}
searchController.searchBar.setImage(UIImage(named: "imgName"), for: .bookmark, state: .normal)

How to enable/disable navigation bar buttons [XCode] (swift)

I was wondering how I would be able to go about changing the status of buttons. I want to make it if one of two text fields has text in them then the button will become useable. I have currently turned off the button from the storyboard. The code I have to check if there is text inside of the text fields is as follows:
Disclaimer:
The code to check if the text field has any text in it works perfectly fine.
#IBAction func textFeildEditingChanged(_ textField: UITextField) {
if FirstName.hasText == true {
self.navigationItem.rightBarButtonItem?.isEnabled = true
print("First name isn't empty")
}
}
The current code that I have in there to set the button to enabled and disable doesn't work however the code to test if the text field has content does work. I just need to figure out how to disable and enable the button of a navigation item.
code that doesn't work is below:
self.navigationItem.rightBarButtonItem?.isEnabled = true
Any help would be greatly appreciated.
Edit: I am using a navigation controller, don't know if that's important or not.
If you are using the storyboard, just connect the outlet then disable it.
#IBOutlet var navigationItemButton: UIBarButtonItem!
then
navigationItemButton.isEnabled = FirstName.hasText

iOS 11 tableView with Style Grouped makes large title become invalid

I gave my tableViewController a large title Style programmatically:
self.navigationController?.navigationBar.prefersLargeTitles = true
and in storyboard, I made tableView "Static Cell" content, and "Grouped" Style in Attributes inspector:
But largeTitle didn't work when I ran the app, if tableView style is "Plain", it works. How can I fix it?
I'm not sure if it's your case, but for me using tableView.bounces = false prevented the large-title from working. Removing this line did the trick.
Where did you put your self.navigationController?.navigationBar.prefersLargeTitles = true. I putted it in ViewDidload and it's works properly
It's not clear to me why this occurs. Quite possibly a bug. But here is a work around. In Document Outline. Select your Navigation Controller Scene -> Navigation Bar then select Prefer Large Titles (at the top) in Attribute Inspector like so:
After making this change, if you want other view controllers to have regular / plain titles, simply add this to viewDidLoad() on that particular V.C.
navigationItem.largeTitleDisplayMode = .never
Remove title from your storyboard
In your UIViewController over viewDidLoad function:
navigationItem.title = "Search title"
navigationController?.navigationBar.prefersLargeTitles = true

Disabled UITextView shows empty context menu on long press

I have a UITextView subclass where I specifically disable all context menu options:
class MyTextView: UITextView {
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
}
I add an instance of MyTextView to a view that shows up in my app. I give the instance of MyTextView the following value: isEditable = false
When I long press on the UITextView however, I get the following:
This seems like a bug since there is nothing in this menu? Any ideas on how to prevent this?
Thanks!
Because selectable property is active. So you can "select" a part of text and iOS default behaviour is to show this popover.
You can disable this property by storyboard, or by code.
Storyboard:
At storyboard, select the textview and go to attribute inspector tab... Search for behavior and uncheck selectable checkbox.
or, if you prefer, you can solve it by code:
at viewDidLoad method, set the property isSelectable to false.
MyTextView.isSelectable = false
That's not "the menu". It's just the thing that magnifies the region where the press occurs:
It's empty in your screen shot only because you've no text, so we're magnifying nothing. The menu appears after your long press ends and the magnifier thing goes away — and it doesn't appear, so your code is working fine.
You can see easily that that's true by changing your code to return true. The empty magnifier will appear, just as it does now, and then when it disappears, the menu appears. Thus, we have proved that what you are seeing is not "the menu".

Prevent UISearchBarController to show UINavigationBar

I'm using a UINavigationBar ALWAYS hidden (I'm using NavigationBar facilities to push ou pop views but I'm not showing it to final user), the problem is that in one of those views I have a tableView with UISearchBar. When I select the searchBar, make a search and click on it's "Cancel" button the NavigationBar appears, but I want to keep the Navigation hidden as it is.
I've tried to hidden the navigationBar one more time by willDismissSearchController or didDismissSearchController by
func willDismissSearchController(searchController: UISearchController) {
self.navigationController?.navigationBar.hidden = true
}
but it did not worked as I want.
Thank you in advance.
I've found a solution, so as it is a unusual question I'll reply for other people know the solution.
the following code did worked for me:
override func viewDidLayoutSubviews() {
self.navigationController?.navigationBar.hidden = true
}

Resources