Is there a way to see what a user is typing in any application while on their iPhone, and then do something based on what they have typed. For example, if a user is typing a text message, is there a way to see what he's typing and hyperlink a word, or display a notification?
Let me know if you require further clarification.
EDIT:
The text monitoring will be happening on different applications; I want to be able to track all typed text, so if the user is typing a note or a text message, I want to be able to track that.
Many of the views associated with text entry have delegate methods, but it does not appear that they will send notifications at the granularity of every character. Of course, you could make your own view and do whatever you want. It's difficult to answer your question without code, but the answer appears to be "yes, but not easily".
Experiment with:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
You'll need to implement UITextFieldDelegate & set the textField's delegate to whatever (e.g.) viewController you're using so you get the message when any change is made to the textField.
I'm assuming you mean within the app that you're coding, & not any other app which may be running - that would be impossible & probably not desirable!
Related
I want to create custom reminder without using alarm, because I have requirement like when a uitextfield 's value increases than previous value the reminder need to be called.
So Is there any way for doing that ???
Thanks in advance
If you want to show an alert if the text entered in the textfield is greater than 1000 in length, then use
1.
UITextField delegate methods. There are methods that get called at every time you enter any character in the textfield. Read more here. You will find a method of your needs.
2.In that method use an if-else condition to check the length of the enteterd text.
Find a property in this link which helps you getting to the length of the text entetered so far in textfield.
3.Use UIAlertView to show alert. Here is the link.
PS: I could have given you the code, but I think it would be more beneficial for you to read these docs and try to implement. In case you stuck somewhere, ask specific questions and we will help you.
I think you have to be more specific, but as far as I get what you need is, if the value increase then previous values. For this you need to store last entered text onto string and if user type new text then compare it and if it is increase then set or show alert view.
Add your logic into this delegate.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
Thanks. Hope it'll help.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Detect key press on virtual keyboard
I wanted to know is it possible to capture the exact keyboard key press time and release time in an iOS application development?
For example, let's say I type "Hello". I'd like to know the H-Key pressed time and release time, then E, L etc. I think the answer will be in microseconds but that is what I want.
Any help would be really useful.
You can use -(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string (from UITextFieldDelegate) to intercept typed characters in UITextField and record the timestamps there.
This at least gives you the release times. Press times are probably much harder, particularly when you consider keys that you have to press longer to get to accented versions of the character.
You will need to make your own keyboard and add events for Touch Down and Touch Up Inside on the buttons where you want to have this information.
Once you have your own keyboard, it is simply a matter of storing the NSDate when the button is pressed, and then subtracting that from the NSDate when it is released in order to get the elapsed time. The time will much more likely be in milliseconds (rather than microseconds) since the run-loop doesn't even go that fast.
I have an open-source project (MIT license) on Github which creates a custom numeric keyboard (you will have to add your own events to the buttons) available which should make implementing a keyboard trivially easy, here: https://github.com/lnafziger/Numberpad
You can add more/different buttons if you want to use letters as well (no code changes should be needed) on this keyboard.
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.
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.
I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values varies. The problem is that the number pad does not contain a key for entering a decimal point.
When I lock my phone, the number pad that comes up to enter a passcode has a custom button to make an emergency call (as seen in the following screenshot):
Numberpad with custom button http://img25.imageshack.us/img25/6426/photoejg.jpg
Does anyone know how to create a number pad with a decimal point button or a custom button (like the emergency call button above)?
Thanks.
There's no Apple-approved way to edit the existing keyboard. If you want them to allow it, file a feature request.
That said, it just so happens that in most applications the keyboard (instance of UIKeyboard) is a separate UIWindow, and you can iterate over the windows in the application and start adding custom subviews that respond to the appropriate touch actions. Find it by iterating over [[UIApplication sharedApplication] windows] and checking to see if the description contains the string UIKeyboard. For more info on this method and some sample code, see this answer.
Another approach is to create your own custom view and build a keyboard from scratch. Be careful if you do this, though, as it requires a lot of manual work, not only in creating the keyboard and getting the touch behavior to match Apple's, but also in any control you add that would bring up the regular keyboard - you'll need to redirect things like becomeFirstResponder to show your own keyboard, rather than Apple's.
Edit: As ZaBlanc pointed out, newer versions of iOS have a way to do this with the inputView and inputAccessoryView properties. See the UIResponder class reference for details.
set UIKeyboardType to UIKeyboardTypeDecimalPad
Available in iOS 4.1 and later.
Create a UIViewController that contains a UIView with a bunch of buttons. Now your keyboard can have whatever you want on it.