UITextView does not respect the secureTextEntry property - iphone

I'm trying to get a UITextView (NOT a UITextField) to act as a password field where the text is obfuscated as you type into it. However, setting this property to YES on a UITextView seems to have no effect and the letters are always visible instead of only being visible if it's the last letter typed and a dot otherwise. Has anyone else run into this and know why this happens or what a possible workaround may be? If necessary I can use a UITextField in the instances that I specifically need password behavior but that would not be as clean as just using UITextView only. Thanks!

I think that specific UITextInputTraits simply does not work on the UITextView. It is intended for password fields (UITextField).

Related

How to customise the default keyboard in Xcode 5

when we click the text field, the default keyboard or keypad not to be appear instead i need to display the custom keyboard..
Did any one know the answer please post it..
Declared in
UIResponder.h
UIInputViewAudioFeedback protocol.
Is this method correct or else there having any simple method to work out?
You need to create a protocol for this for having a custom keypad appearing throughout the app. I have made it few months back and the stuff was working well. My requirement was to create a keyboard for farsi language, because ios does not have farsi in its language settings.
There is no need to make protocol if you want it in just 1 viewcontroller.
Here is my that thread:
customized keypad on the iPhone Application
Here's something that I created that might help. Just fork it on GitHub and change the Punjabi characters to Myanmar. Most of the hard work is done for you :)
https://github.com/kulpreetchilana/Custom-iOS-Keyboards
Per your comment you need the Number Pad keyboard.
Set your UITextField keyboardType property, either via Interface Builder or programmatically:
textfield.keyboardType = UIKeyboardTypeNumberPad;

Iphone SDK, switch keyboard in app

I have one question, may be it is very simple, but I do not know about this nothing...
For example, I have an application, application with textfield, I want to know two things.
First: Is possible to switch keyboard when application in runtime?
Second: how I can switch type of keyboard(Russian, English, Swedish, etc.) in my application*?
*-without going to Settings->General->Keyboard->add new keyboard.
Not sure about changing languages (I did find this other post about it: change input source language programmatically OSx), but changing the keyboard is pretty easy. Here is a one line example:
textField.keyboardType = UIKeyboardTypeURL;
Take a look at the UITextInputTraits protocol reference for more info. Then the question comes in where to implement this. I am assuming that you want to check conditions right before the keyboard comes up, you may have to implement UITextFieldDelegate protocol (and maybe using the field's tag to see which field the cursor is in).
Hope this helps.

Detecting when UITextField text has changed due to shake undo?

I have a UITextFieldDelegate that does a whole bunch of validation on user input to determine whether or not they should be allowed to end editing. In one particular example, it is not valid to leave the field blank.
Right now I'm using textField:shouldChangeCharactersInRange:replacementString: to validate the text input after each edit by the user.
The problem is this: if the user clears the field (with the little 'x' button), the validation code goes into "invalid" mode and prevents the user from navigating away until they have entered valid text. If the user then shakes the phone to get the old text back, shouldChangeCharactersInRange is not called again and the delegate stays in the "invalid" state instead of recognizing that everything is fine again.
Not sure if I'm using it correctly, but it seems like the built-in UITextFieldDelegate machinery is not able to cope with text changes due to undo / redo.
What's the best way to achieve proper validation in this scenario? Do I really need to subclass UITextField in order to implement motionEnded:withEvent:? Seems like the edit-handling stuff in UITextField should really be independent of whether the user actually typed it or it happened due to undo, so would be bummed if I actually had to go that route.
Hook up a method to the UIControlEventEditingChanged event ("Editing Changed" in IB -- not "Value Changed").
This appears to fire whenever/however the text field changes.

Programmatically pasting into an iPhone UITextView

I have an iPhone app with a UITextView. I'd like to be able to paste the clipboard contents into it without showing the UIMenuController.
I tried calling the paste: method on the UITextView, and on the first responder, but neither of those things worked.
I was able to implement this by writing a bunch of code to read text from the clipboard, insert it in the UITextView's text property, and update the selection range. I also added support for undo/redo. But it seems like there ought to be an easier way. Is there?
Did you try paste with nil sender?
[theTextView paste:nil];
as per UIResponder docs
Did you try making the UITextView the first responder?
I checked out the headers to the UITextView object, but I couldn't find any documented method called -paste; also, looking over the NSPasteboard class suggests to me that programatically setting your text was the right way to go.
If pasting text is important to your app, I would consider setting up a class to handle it; maybe even make it a singleton if it was important enough.
Good luck!

(iPhone) selectedRange for a non-editable UITextView (or other methods of click handling?)

I'm using an UITextView to hold static content (in Chinese, which means that the characters are all fixed width). I want to let users click on a character in the text and bring up dictionary information for that character. I know all of the issues surrounding the lack of copy and paste and all that, but I'm hoping that there will be a way to do this without waiting for the iPhone 3.0 firmware.
At first, I thought about using UITextViews selectedIndex property. Unfortunately, when the UITextView is not editable, the following code in the UITextView's always returns the length of the entire text block:
NSRange touchPoint = self.selectedRange;
NSLog(#"Selection: %d", touchPoint.location);
This makes sense, I suppose, as with a non-editable UITextView there's no way to select an insertion point, but it's doesn't help me any. :)
Another approach would be to calculate, using the fact that the Chinese text is fixed width, where the click landed and what text should be under that location at the time, but this is complicated by punctuation which can cause a line to wrap early, bringing preceding characters down a line.
Is there another way of know what text is under a touch event that I'm missing?
Call the following before asking for the selectedRange:
[[textView webView] updateSelectionWithPoint:point];
Note: Both -webView and -updateSelectionWithPoint: are private APIs. You can alsoperform the equivalent behavior by toggling editable, becoming first responder and sending fake touch events, but that would be much more work