I would like to animate the user entry and deletion character by character in UITextField. For example, I want each character bounce in and bounce out when user is entering or deleting them.
Is there a formal way to do that by overriding some methods in UITextField ? Or I need to do a trick by using another UILabel or somehow, do you have an idea ?
Thanks in advance.
Related
I want to use a UITextField so that only part of it will be editable.
I know about the delegation and shouldChangeCharactersInRange but for some reason, copying the ranged part is allowed.
My goal is to get similar result to this (the 'subject' text part) without being able to copy it.
Should i use a different UITextField with textFieldDidBeginEditing returning false all the time?
Is there a better solution?
In the screenshot, a UILabel placed next to the UITextField is used. I'd recommend doing this as it will give you more options when you decide to style the text.
I need to manually turn caps lock on, on the keyboard.
Using autocapitalizationType property won't do the job. The problem is I am implementing a bullet list feature, where after the user inserts a bullet I need to turn on the capLock right away. This doesn't happen using standard autocapitalization because the first letter in my paragraph is #"•" rather than the text the user needs to enter.
Any way to turn capitalization on manually?
I had a similar issue a while back and what I ended up doing was using the UITextFieldDelegate or UITextViewDelegate depending on which control you are using they both contain textField:shouldChangeCharactersInRange:replacementString: or textView:shouldChangeCharactersInRange:replacementString: which is called every time the content of the field is changed. This allows you to change the character values automatically.
Hope this helps.
You can check out the documentation here: https://developer.apple.com/library/ios/documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html#//apple_ref/occ/intfm/UITextFieldDelegate/textField:shouldChangeCharactersInRange:replacementString:
I'm new to objective-c, and I've done this in Flex/Actionscript, but hitting a wall with IOS. Is it possible to get the index of a character under a point(x,y) in a TextField or Label and then be able to modify that single character in IOS?
I have a TapGestureRecognizer coming in with a point in my view. I need to now be able to isolate and highlight just the character at the point coming in.
For example if I have the text "Hello" on screen and I ask them to click on the 'e', I need to know which letter they touch and highlight it green/red depending on if they were right or not.
UITextField (and UITextView) conforms to the UITextInput protocol which has the method characterRangeAtPoint:.
Once you have the CGPoint from the gesture, use this method on the text field to get a UITextRange. Then use the textInRange: method to get the text associated with that range.
I have a UITextView with some text. This text is an Attributed String(NSAttributedString). There are certain portions of the text that i have set to bold, and want to add a TapGestureRecogniser to those specific words only.
Till now, i have been using the textViewDidChangeSelection method of the UITextView delegate. But this is causing issues in other parts of the project.
Is there a more direct approach to this ?
You can only add a GestureRecognizer to a view, not to some words.
It's a quite complex task, there's no easy solution for it.
I can think in some approaches, for example:
Place a transparent view on top of the bold words to get the Tap.
Detect the Tap in all the UITextView, and then calculate based on the position of the touch and the position of the bold words if it hit one.
Both options requiere a lot of code and a lot of edge cases where it can fail.
As I said, it's a really complex situation, you may want to keep using textViewDidChangeSelection and fix the issues, we can help you.
I'd like to place some fixed text inside an UITextField, but before the insert point, sort of like this:
| He went (towaards)
...where "towaards" is the editable part.
The point is to show the editable text in context.
Is that possible, and/or are there better alternatives?
I guess you can do that by implementing UITextFieldDelegate. There is one method – textField:shouldChangeCharactersInRange:replacementString:.
In this method you can check each and every character which is entering by user (even backspace). So first you implement change in another NSString object then validate with your condition.
Check whether new string passes through your validation then replace the old string with new string, otherwise leave it as it is.
For example, check new string starts with your string or not. You can use this:
[myString hasPrefix:#"He went"];
Here in the same method you can also do one more thing, when user taps on UITextField check if #"(towaards)" string is there in textField then remove that text by code.
Hope this is what you want.
Just set the text property of the label to #"He went (towaards) and when editing is started change it to #"He went "
I don't think you can put noneditable and editable text in the same UITextField.
What about putting a UILabel with the noneditable text right beside the UITextField ?