Hi All,
I created UIFormattedTextField as a component. I would like to
provide the gist of conversation between me and the Architect during
development here.
The Architect of my project always encourages the team to develop reusable components and use that in the project.
Current project requirement is to get the amount as input from the user.
Demo1:
So I started working on it. I created a normal textfield which accepts
both number and character. But while submitting the form it gives an
error, “Please enter only number”. I demoed it.
Architect: Hey we are developing this for mobile device. The current
implementation will annoy the user. So modify the text field, which
accepts only number instead of giving the error at last.
Demo2:
The real development, googling, coding everything starts here. Changed
the text field to accept only numbers and dot and it will format the
number by putting commas.
Architect: Good work man. This is a currency field right. why can’t we put a currency symbol?
Me: We can place a label before the text field and put the symbol, simply we can hard code and finish it off.
Architect: Then its not dynamic. Put the symbol in the text Field
itself. Also make it localized. So when I change the device location to
India it should show Rupee symbol and format the number according to
Indian format.
My mind voice: Super. Google will help me.
Demo3:
Done all the comments given in demo2. So now the text field will format
and show the currency symbol according to current location.
For India:
For US:
Architect: Super. Its looking good. So why can’t we make it as a
component so that I can set the type of the text field as Currency,
Number, PhoneNumber, SSN etc and text field should behave according to
the given type.
Me: Yes we can.
Demo4:
Everything done. Now we can set the type of the text field.
Architect: Ya good. Ok now we can start using this. Circulate this to all our team members.
Me: Ya sure. But while working on this, I thought, instead of giving
the type separately, like PhoneNumber, SSN etc. I will remove all these
types and give an option dynamic. So you can set the type “Dynamic” and
define your own pattern in the format xxx-xxx-xxxx (for US Phone
number), xxx-xx-xxxx (for SSN) so we can avoid lot of options.
Architect: That is also good option. Do that and distribute across team.
Everything done. Now the text field accept the types,
1. Currency
2. Number
3. FormattedNumber
4. Percentage
5. Dynamic
If you look at the code, you can see some other types too which is used
before the introduction of Dynamic. Now you can achieve the same using
Dynamic and FomatPattern.
After this entire development, I learnt how to think and design
before actually start our coding. Thanks to my Architect who taught me
how to think “Mobile” while developing each and every feature.
How to use the component in your iOS projects:
1. Drag and drop the “UIFormattedTextField.h” and “UIFormattedTextField.m” files to your project.
2. Import the header in your class, where do you want to use it.
#import “UIFormattedTextField.h”
3. If you are using xib or storyboard, change the class of the text field in the “Identity inspector” to UIFormattedTextField.
4. Create an instance variable to access the text field.
IBOutlet UIFormattedTextField *currency;
5. Set the type and delegate of the text field. Don’t forget to import the delegate <UITextFieldDelegate>
currency.type = @”Currency”;
currency.delegate = self;
currency.numberOfDecimalPlaces = 3;
6. You have to change the delegate function ,
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return YES;
}
to
-(BOOL)textField:(UIFormattedTextField *)textField
shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString
*)string
{
return [textField shouldChangeCharactersInRange:range replacementString:string];
}
7. You are done.
You can download the sample project here FormattedTextFieldDemo.
Screenshot:
Showing posts with label iphone. Show all posts
Showing posts with label iphone. Show all posts
Monday, January 20, 2014
Friday, May 3, 2013
Speech to Text Apis
Hi All,
Most of the people don’t prefer to write. Instead, they search for alternate options in order to save time. If nothing is feasible, then only they choose to write. This paved way for lot of technological advancements like Xerox machine, Scanner, Printer etc. Same way, when it comes to mobile device, people don’t prefer to type because of the smaller size keyboard and other constraints.
One of my friends recently bought a big screen smartphone. It is not comfortable to place the phone in pocket because of the size. I asked him why didn’t you buy a normal size phone. He replied that in this big screen itself he had difficulties in keying-in the keypad letters. Seems most of the time he touched two letters instead of one.
Same way, when you are driving or doing some other work, you will find it difficult to pick the phone and type. This is the place where speech to text conversion plays an important role. I used couple of speech to text APIs in my iOS apps. Here are some frameworks which might be useful for you too.
1. OpenEars
This is a open source framework available for iOS. We can directly download the framework and start developing the apps. It supports both speech to text and text to speech conversion. This works completely offline. The only downfall is since it works offline, you have to define a dictionary of words you want it to recognize.
This library is very much useful when we want to pick only certain words from speech. e.g.: I used this library for navigating views and filling datas in an application. When the user says “Go to Home”, the app will navigate to home page. Also I can fill the form data (refer screenshot of the app) as, “set current age 25″, “set gender male” so the app will fill the data properly.

Here I created the dictionary with the words I want the app to recognize. For directly converting all the speech to text, we have to build the dictionary containing all the words so that it will recognize the speech and convert it into text. Words database are already available in the net. We can directly use that or we can use our own set of words.
http://www.politepix.com/openears/
2. SpeechKit
This is another framework which will convert speech to text using a server. Implementing this framework is much easier than OpenEars. We don’t have to define dictionary of words or anything, just open the view already available with the framework. (it will give us the UI also). It will recognize the speech and send us the text in a callback function. The only drawback is that it needs internet connectivity.
http://dragonmobile.nuancemobiledeveloper.com/public/Help/DragonMobileSDKReference_iOS/SpeechKit_Guide/Basics.html
Also there are lot of other frameworks available for converting speech to text. We have to decide the one which fulfills our needs.
Bye Till Next,
- Jeyabalaji
Most of the people don’t prefer to write. Instead, they search for alternate options in order to save time. If nothing is feasible, then only they choose to write. This paved way for lot of technological advancements like Xerox machine, Scanner, Printer etc. Same way, when it comes to mobile device, people don’t prefer to type because of the smaller size keyboard and other constraints.
One of my friends recently bought a big screen smartphone. It is not comfortable to place the phone in pocket because of the size. I asked him why didn’t you buy a normal size phone. He replied that in this big screen itself he had difficulties in keying-in the keypad letters. Seems most of the time he touched two letters instead of one.
Same way, when you are driving or doing some other work, you will find it difficult to pick the phone and type. This is the place where speech to text conversion plays an important role. I used couple of speech to text APIs in my iOS apps. Here are some frameworks which might be useful for you too.
1. OpenEars
This is a open source framework available for iOS. We can directly download the framework and start developing the apps. It supports both speech to text and text to speech conversion. This works completely offline. The only downfall is since it works offline, you have to define a dictionary of words you want it to recognize.
This library is very much useful when we want to pick only certain words from speech. e.g.: I used this library for navigating views and filling datas in an application. When the user says “Go to Home”, the app will navigate to home page. Also I can fill the form data (refer screenshot of the app) as, “set current age 25″, “set gender male” so the app will fill the data properly.
Here I created the dictionary with the words I want the app to recognize. For directly converting all the speech to text, we have to build the dictionary containing all the words so that it will recognize the speech and convert it into text. Words database are already available in the net. We can directly use that or we can use our own set of words.
http://www.politepix.com/openears/
2. SpeechKit
This is another framework which will convert speech to text using a server. Implementing this framework is much easier than OpenEars. We don’t have to define dictionary of words or anything, just open the view already available with the framework. (it will give us the UI also). It will recognize the speech and send us the text in a callback function. The only drawback is that it needs internet connectivity.
http://dragonmobile.nuancemobiledeveloper.com/public/Help/DragonMobileSDKReference_iOS/SpeechKit_Guide/Basics.html
Also there are lot of other frameworks available for converting speech to text. We have to decide the one which fulfills our needs.
Bye Till Next,
- Jeyabalaji
Labels:
api,
ios,
ipad,
iphone,
speech to text,
text to speech
Subscribe to:
Posts (Atom)




