How to append placeholder to textview/textfield after user begins editing - ios

I am trying to create a textfield input, that forces the user to enter a email address but forces the domain (the domain logic is validated when the user enters return), so the user enters a email associated with that domain only. This needs to be very clear on the UI itself, I've tried using the UITextField but since the placeholder is cleared after the user starts editing it doesn't work so well. Here is a sample screenshot of the Slack app that shows similar textfield-
Eg. The user enters team domain, and ".slack.com" is appended to the user text.

Setting up a NSAttributedString as the textField.text from textField:shouldChangeCharactersInRange:replacementString: invocations will give you the desired behaviour.

When the user stars typing you can append the ending domain to what the user types. You can also play with attributed strings changing the color of the appended text so it looks as it's still part of the placeholder. This should be done intextField:shouldChangeCharactersInRange:replacementString:
Check the official documentation https://developer.apple.com/reference/uikit/uitextfielddelegate/1619599-textfield?language=objc
For setting the cursor in the desired position you can use UITextPosition which is extensively explained in this answer

Related

Place Autocomplete in iOS (swift) on Signup (address) form

I am a signup form which has bunch of text fields like name, phone, address 1st line, city, state etc.
Can I use googles's Place Autocomplete on this form in such a way that when I start typing address 1st line in one of the fields it suggests/auto completes and fills the city and state
1st question, is it possible, if yes are there any examples or tutorials?
There are examples out there but they use autocomplete UI, I want to be able to use my own edit text fields.
So Yes I was able to do exactly what I wanted.
I had two dependencies for this.
1. AutoComplete Text Field
2. Google's Place AutoComplete

iOS: Accessibility support for dynamic labels / validation errors?

I want to enable accessibility support in my app where i have In-line validation message (e.g As per below screenshot) when user enters something invalid data. My app doesn't show any error message.
What can be best and intuitive way to inform visual impaired/blind user about wrong data entries. e.g. Username & password mismatch, invalid.
First off, there is no "correct" way to do this. There are just a bunch of ways that work. The "best" way to do this, would be for iOS to have a "required" trait (IMO). But this is not supported, so we have to work with what iOS has given us... hints and labels.
Step 1:
Tell the user what is required. I would do this by adding the information to the hint. I like to add information to the hint that only non-familiar users need. "Power users" of your application will get use to what fields are required (assuming you're going to have return users, some views are just "hit and run" types). But, point being, don't flood users with unnecessary information. Users who visit a particular view frequently will get use to what is required, so keep non-crucial information in the hint. What you want is voiceover to read out the text input fields like this: "Email(accessibilityLabel) text field (the type of object), (pause) This field is required.(hint)" Don't wait until after a failure to provide this information to VoiceOver users. It should just always be set this way. If the type of failure changes, change the hint to adapt to this particular type of failure. If you'd like to keep the hint in sync with the Red highlighted labels, you can consider overriding the functions from the UIAccessibilityProtocol to pull out this information EX:
- (NSString*)accessibilityHint {
return myUILabel.text;
}
This should cause to keep the hint of the object, and the text of your UILabel in sync.
Step 2:
Mark all elements that are not the text input fields, as not accessibility elements. All of the information a user needs about those fields is either stored in the type of the field (a text input field), the label (email/password), or the hint (whether or not it is required). Therefore, we don't want VoiceOver to look at the other elements, because this would be duplicate information.
Step 3:
Use the following line of code:
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, anAccessibilityElement);
In your login action. On a failed login action, you should shift voiceover focus to the element that caused the failure. This informs the user that their action was attempted, and that it failed. It also allows them to easily know which element caused the failure, and that it needs fixed. In the event of multiple failures, make sure you shift focus to the first failure!

Is there a way I can get the text that has been typed into a text field in the app (by user) to be sent to me?

The only thing I don't want is to make users open up the ComposeMail viewcontroller. I just want them to type text into a text field (or multiple text fields), hit a 'submit' button, and somehow, that text be sent to me.
I was thinking that it could be sent as an email without the viewcontroller if I set the email address as some random address like example#gmail.com, or something.
THANKS

Add alternative text to a phrase in a document file

I use LibreOffice Writer and I want to insert an alternative text to a specific phrase in the document, how can I do it?
Example if we have an image in the document we can make double left click and add the alternative text like this:
Is it possible to make the same if we select a whole phrase of text? If yes how? And if No is there any other proposal?
The alternative text in 'word'/odt documents is actually intended as the 'alt' attribute in HTML (web) pages:
The alt attribute provides alternative information for an image if a
user for some reason cannot view it (because of slow connection, an
error in the src attribute, or if the user uses a screen reader).
(http://www.w3schools.com/tags/att_img_alt.asp)
It's only purpuse is thus to provide the user with information in case he/she can not view the image. Since having alternative text in case some text cannot be displayed is, well, silly, this 'alt' attribute is not defined for pieces of text. Alternatively, you could have a hyperlink pointing to nothing ("#"), which does provide a tooltip attribute.
What is it that you're intending to achieve anyway? It's not going to show up on any prints, which is the intended purpose of Writer... Footnotes (for prints) or Comments (for communication with co-editors) might suit you better.

How to use a TEdit box to enter password without showing the characters that is bing entered and only showing a *

I want to make an edit box where an user must enter a password. When they enter the password I want the character not to be displayed, and rather an *. Are there any properties that can be set to do this, I know how to set the TEdit to remain blank while entering but I do not want that. Im using Delphi XE2
I remember from my old days in Delphi that TEdit had a property for that.
Searching on Google, I found this
Namely: "Use the PasswordChar property to create an edit control that displays a special character in place of any entered text."
I have seen that in the TEdit there is a property named PasswordChar. I assigned the * value to it and now the Edit box does not show the characters that is entered into the box

Resources