Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A piece of code that will automatically format a uitextfield with a numberpad to behave like an ATM

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 HMFCurrencyFormatter.h
Octocat-spinner-32 HMFCurrencyFormatter.m
Octocat-spinner-32 README.md
Octocat-spinner-32 buttons.xcf
Octocat-spinner-32 toggleButtonDown.png
Octocat-spinner-32 toggleButtonUp.png
README.md

HMFCurrencyFormatter

A piece of code that will automatically format a uitextfield with a numberpad to behave like an ATM

Here's an example

Create a property for the formatter

@property (nonatomic, retain) HMFCurrencyFormatter *priceFormatter;

In the viewDidLoad make sure to initalize

self.priceFormatter = [[HMFCurrencyFormatter alloc] init];

Wherever you setup your textfield set the priceFormatter as the delegate

myTextField.delegate = self.priceFormatter;

To automatically add the "+/-" button to the numberpad (iphone only) call this method.

[self.priceFormatter startWatchingForKeyboardFromTextField:myTextField];

(optional) if you want to handle the delegation yourself you can do this also.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

 textField.text = [HMFCurrencyFormatter formatTextField:textField withReplacementString:string]
 return NO;
}

If you have a textfield in a UIAlertView be sure to call "startWatchingFor..." everytime you show the alert.

You're done!

Something went wrong with that request. Please try again.