How can I get my text appended to the placeholder programmatically - ios

I want to add a variable place holder in my textField and when something is written in textField, that text should be appended to place holder without any change to place holder. How should I go about it?

you can do this by using clearsOnBeginEditing property and set it to FALSE.
textField.clearsOnBeginEditing = NO;
If you are creating textfield by interface builder then you have to go to inspector in Interface Builder(Press command 1) and finally you have to uncheck the Clear when editing begins option.

Related

How to move placeholder up while typing in the textfield? is it possible just from storyboard? or code in IOS Objective-C?

I have set the values of placeholder
self.baseURLTextField.placeholder = ServiceUrl_English;
self.paymentBaseURLTextField.placeholder = PAYMENTSERVICEURL_ENGLISH;
I just want to move the placeholder up while editing or typing in textfield. is it possible through just only storyboard? or code in Objective-C.
Not really the way you intended it. Placeholder is just a hint of what should be typed in the textField and it's supposed to be removed once text entry starts.
If you want the placeholder to "move up" I suggest you either prefill the textField with the text you want to preserve, or simply add the text at the point user starts typing in, and move the cursor to where you want the user text to start.
You can achieve this by putting a UILabel at the top of the text view then show/hide it whenever the user starts typing.
Or you can use a pod like JVFloatLabeledTextField

Hide TextField selection handles

Im my application when the user selects a TextField the existing text gets automatically selected when the Focus changes to the textfield. How do I hide the blue selection handles that appear?
The reason I want to automatically select the existing text is so that the user can begin typing and the textfield will automatically overwrite the existing value instead of appending to it.
I figured it out. You can set the enableInteractiveSelection property to false.

How to remove "border-radius" from default UITextField?

My question is, how do I remove the "border-radius" of the textfield in Swift? Is it achievable in xCode or do you need to do a customized textfield? If so, how do I do that? I want the default textfield but without it's "border-radius" if you know what I mean.
Help, please!
UITextField has an attribute borderStyle, which can be changed either in interface builder:
...or in code:
public var borderStyle: UITextBorderStyle // default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.
You can set the border style using Storyboards.
And also you can set border style programitically
[txtUserName setBorderStyle:UITextBorderStyleNone];
What do you exactly mean with border-radius? the border around it?
You can turn that off by clicking the button in xcode:
Or if you want to do it programmatically do:
myButton.bordered = false

UITextField clearsOnInsertion does not working

I set
textField.clearsOnInsertion=YES
but nothing happened. I am using XCode 5.0 and iOS 7.0
You should firstly make it clear what is clearsOnInsertion. See Apple's doc:
clearsOnInsertion
A Boolean value indicating whether inserting text
replaces the previous contents.
Discussion
The default value of this property is NO. When the value of
this property is YES and the text view is in editing mode, the
selection UI is hidden and inserting new text clears the contents of
the text view and sets the value of this property back to NO.
clearsOnInsertion is very useless in my opinion. See the screenshot:
The text field is in editing mode and the keyboard is shown but the selection UI is hidden. When you input any thing, it will replace the old text. That's it.
Another related useful property is clearsOnBeginEditing
clearsOnBeginEditing
A Boolean value indicating whether the text field removes old text when editing begins.
Try this:
textField.clearsOnBeginEditing = YES;
if you want to clear previous text when editing begins you should use
textfield.clearsOnBeginEditing = YES

How to select a UITextField without showing UIKeyboard

I am wondering if there is a way to use a UITextField programatically (i.e. use buttons as inputs) so that you can select a UITextField but not show the UIKeyboard, then when you select a UIButton it would assign a string value to the currently selected UITextField.
I don't really know where to start.
I think you can visually change the appearance of the text field (for example add a blue border), let the user feel it’s “selected”. Then you just modify textfield.text when user presses button.
Or alternately, you can create a customized keyboard. There are many similar questions.
It seems that you don't really need a text field (e.g., edit/select text, etc.), but a "button that stays highlighted" instead. Then, you can programmatically change the button's title label to the specified string when the user taps the 'proper' buttons.

Resources