I'm beginning to learn Xcode and as the first app i decided to write a calculator. I did everything and it works pretty good but there is one thing i couldn't find. I want when the user writes Letters instead of numbers and taps the button , an alert appear and prevents him from entering letters.I'll appreciate you if help me and sry for my bad english.
If you don't want to allow the user to type letters at all you'll be much better off using the numeric keyboard. The decimal numeric keypad is available in iOS 4.1 and up, and you can find out more about it from this question:
How to use the new UIKeyboardTypeDecimalPad feature in iOS 4.1 SDK
As the comment said, you'll probably be better off just changing the input type of the keyboard.
[myTextField setKeyBoardType:UIKeyboardTypeDecimalPad] // has a decimal, use UIKeyboardTypeNumberPad for no decimal
See list of all available types here.
Related
I'm trying to implement the transfer of a one-time code from SMS to the field above the keyboard, as in the image.
But for some reason the field above the keyboard is not displayed.
Code:self.valueTextField.textContentType = UITextContentTypeOneTimeCode;
UI hierarchy:
+UIView
CustomContentView
UIImageView
UITextField - valueTextField
UITextFieldContentView
I have read these materials:soQuestion and apple docs , and I saw a warning:
If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.
... but I do not understand what is meant by custom input view.
Also I have category for UITextField. Can it affect the work?
I will be glad to any ideas, thanks!
Okay. This is what I could find out. Regarding the code, it is enough that I described above. Additional settings on the client is not required. But you need to pay attention to the text of the SMS message. As an example, I attached two messages.
In the first message, our code is defined by the system as a phone number. We can even call it if we click on it. But why do we need to call a one-time code? :)
In the second image, the code is defined as one-time, just what we need. If we click on it, the system will offer to copy it to the clipboard.
What is the difference? Unfortunately, it is not completely clear by what rule the text is parsed in SMS. But we can check your text in the following way:
If you set a property textContentType to your text field and nothing works for you, the first thing you need to check is whether the operating system determines the code correctly. To do this, simply go to the message application and check the code:
blue font color with underscore - the system did not recognize
one-time code.
black font color (as default) with a gray underscore - it's okay!
At the end, in the first case, you should check the text of the message for the contents of incorrect characters.
PS Just a couple of examples of correct and incorrect SMS:
SMS-code: 12345 £ correct
SMS-code: 12345 $ correct
SMS-code: 12345 № correct
SMS-code №1: 12345 incorrect
I got caught out by the fact "Autofill PAsswords" was turned off on the phone.
It seems that it needs to be on for this functionaility to work.
Is there a way to get a NSLocalizedString in its untranslated states, for example getting it from a NSTexfield/label or popup button as below:
_mylabel.stringValue
or
[_myPopupButton titleOfSelectedItem];
Obviously returns a translated string depending on the current OS language.
This is inconvenient if I want to know and use a statement comparing what I find at the time, whereas users can also translate or adjust to their liking the stringsfile.
Any suggestion or workaround?
Initially the problem was that I used "NSUserDefaults standardUserDefaults" to save what was on the buttons on a plist, so when I restart the app would have taken those descriptions initially were created using simple strings if the plist did not contain all the dictionary needed (to return into my button), as if app was open for the first time).
It's enough to localize everything, even when re-reading or create the "empty" settings, so it does not matter if the preferences are written in another language: my button now return what the app found on the plist created by "NSUserDefaults standardUserDefaults"!
(sorry for my poor English)
I don't know the specific name for this button, but it is the one with the microphone that when you press it, it allows you to speak, and it will convert your speech into text.
I haven't been able to find anything on this, but when I click to edit a textfield I want that button to be pressed automatically so I can just begin to speak and then click done so that it will convert the audio to text.
I don't know if this is possible and can't seem to find anything on it... Probably because my search is weak since I have no idea how to ask it.
If anyone knows how to do this, or knows where there is anything on it, I would appreciate it greatly.
You cannot do that.
That is a part of Siri.
Till now Apple not provided any api to interact with siri.
I'm looking for a show to show the "split keyboard" instead of the regular one.
I know that the user can drag the regular and show the "split", but is it possible to show directly the split?
Thanks (and sorry if very easy!)
No, you can not pre-set the location of the keyboard. It starts off in the way it sees best, and the user can adjust it if needs be.
I have a question about detect and change input from bluetooth numeric keyboard and sending text to another applications.
My customer asked me, if it's possible this:
my customer has bluetooth numeric keyboard and he wants to use it like phone keyboard (that means one press of number 1 it's letter A, double press it's letter B etc.)
he wants this behavior of keyboard in general for all of applications in iPhone (in email app, SMS app etc.)
I'm not sure, but i think that it's not possible, because i think the application on background cant't modify key input for another apps. Or is here any way how to do that?
Something like this may be possible via a jailbreak app but definitely wouldn't be possible using the regular SDK.
If this isn't meant as a mass market tool, perhaps jail breaking is an option? I would check this out and see if it's any help http://iphonedevwiki.net/index.php/MobileSubstrate