How to implement a UITextField similar to email Text Field in MFMailComposeController - ios

In MFMailComposeController, once we start typing, the list of email addresses is shown. Once we select, the TextField displays the name of the user with a small Oval background. Then we can continue typing. If we want to delete it, then pressing backspace selects the oval background and on second backspace the email address is deleted. How can this be implemented.
I am not interested in the search part. I am fine with Implementing it. But I am more interested in getting the TextField working as in the MFMailComposeController. The way the blue oval background is set for already typed in emails.
Thanks

If you simply want to search through a set addresses,strings or whatever you can implement UISearchDisplayController and you will getyour job done.Here's the link on UISearchDisplayController iPhone.
Else , if you want to have youown you have will have to have a UITextField with a UITableView and you will have to implement the delegates method of UITextField to get the autocomplete feature searching through tableview's datasource.Implement your logic using delegates of UITableView and UITexField.

you can use many open source implementation one name from them is TITokenFieldView.

Related

Is there a way to hide a textfield but keep the keyboard open?

I am creating a PIN input view (basically the same thing as iPhones already have, I just could not find a way to reuse the existing to authenticate my users from my user pool).
I made 4 circles with a stroke that represent the PIN code, when a user taps a button on my custom PIN keyboard, I append the key tapped char to the pinAttemption string and make the circle representing the digit of the PIN filled.
I made a custom keyboard for this with UIKit's UIInputView, that I attach to a custom UITextField and wrap the whole thing in a UIViewRepresentable to expose it in SwiftUI. I make the UITextField firstResponder to make sure the keyboard is presented as soon as the user navigates to the PinInputView.
My plan was that I hide the UITextField and somehow render only the dots.
My problem:
I cannot hide the UITextField with .hidden() as that will also hide the keyboard. I also don't just want to set the opacity to 0, because I guess in that case the user could still tap the field again? I feel like that is not appropriate?
What would be a good way to go about this?
p.s. I am a beginner with SwitUI and UIKit.

Is it possible to add a Done key to ALL keyboards in an app?

Is it possible to add a done or cancel key which dismisses a keyboard to all keyboards in an iOS app? There are several posts asking how to dismiss a keyboard via a cancel or done button, but the solutions are on a field by field basis.
Are there any solutions that add this functionality globally so the code wont need to be duplicated for each textfield/area in an application?
Like #silentBob says in his answer, the inputAccessoryView of a text field is the view that’s displayed immediately above the keyboard when the text field is the first responder. If you didn’t want to write an extension on UITextField to override the -inputAccessoryView method, you could also create a subclass of UITextField to do the same, which would make it easier to determine which method is going to be called. You could also have multiple subclasses of UITextField to customize which button(s) appear. If you have a text field in a storyboard, you can simply change the class to your custom subclass, so while you have to go through and make those changes, you don’t have to do it in code.
Yes, you can add an extension to UITextField class, which should add a UIToolbar with Done and Cancel actions as UITextField inputAccessoryView.
Well, In that case you have to customise the keyboard, built your own keyboard and do whatever you need to do with your key in the keyboard.

HKTextview emoji detection

I'm having an issue. I am using the Hakawai framework in an app so that I can have mention support (#username).
The issue I've run into is that the textfield I am using is not registering the case where there is no text and a user types an emoji into the textview. As we are using HKWTextView, I believe the textViewShouldChangeTextInRange delegate method is never called, even if implemented. The only replacement I can think to use is :
- (void)textView:(HKWTextView *)textView didChangeAttributedTextTo:(NSAttributedString *)newText
originalText:(NSAttributedString *)originalText
originalRange:(NSRange)originalRange;
in HKWTextView, but that's still not picking up on emojis being typed in when no other text has.
The functionality I would like is:
- Text view is empty
- user types in anything, emoji included
- textview width shortens, "Post" button appears.
Right now, typing emojis into the empty text view will not make the post button appear. However, it's worth mentioning that once the emojis are typed in, if there is more than one, deleting one of them WILL make the post button appear. I'm at a bit of a loss here.
I found the answer to this - It turns out that HKWTextView does some rewiring of the UITextView delegate methods that are fired. Try handling the input in the UITextView delegate method textViewDidChangeSelection. That method will be fired when an emoji is typed.

UItextfield to appear on touching (uitextview word)

I am working on an app that has an uitextfield with some wrong content now user touches the wrong word , a new text field appear on that part , user enters the correct word and then submit.
I have succeed in fetching the correct word on touching the texview but have no idea how to deal with textfield.
Please suggest a good solution for this !
You will want to look at the UITextFieldDelegate Methods in this case. You can search SO for samples but check out the documentation to get the big picture. Basically, you'll want to intercept the messages to verify that the user entered the correct text and then do something with the information provided by the user. Including things like dismiss the keyboard, add result to a score or do something else with the data (per your app design).

Curious Warning Message on UITextView

Has anyone run across this warning message building for the iPhone?
More importantly do you understand how to fix it?
"unsupported configuration data detection and editable"
It's seems to be the UITextView that is complaining.
Here's a screenshot.
The problem is that you have that textview set both to editable + to detect/autolink phone numbers, events, addresses, etc. a text area can either be editable and not detect/autolink text, or it can autolink text but not be editable.
Your settings for that textview should look like:
or
but not like:
I think in your scenario, the text input is only used to input text, nothing more. Then when it get's presented back, the "presenting text view" will take care of detecting the potential information... dates, events, etc.
To be more precise : in a simple app scenario, a user types in some text (let's say an event input text view - with no detection necessary at this point). Then when it get's eventually presented back to him or another user (let's say the detail view of the event), the text will be presented back in a "non-editable" text view that in turn will be able to have detections.
I know this question is a little old, but this is how I resolved it;
In Interface Builder I have Links Detection selected, and Editable Behaviour not selected.
Then, in my ViewController, I implemented the UITextView - (BOOL)textViewShouldBeginEditing:(UITextView *)textView { } delegate method and return NO.
It removed the warning and prevents the user from being able to edit the UITextView's content.

Resources