Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Adds a Done and Cancel buttons to an iPhone Number Pad

branch: master
README.md

Adds Done and Cancel buttons to an iPhone Number Pad

example

ViewController Header

Add the include, delegate, and textfield to your header file

#import "DoneCancelNumberPadToolbar.h"

@interface ViewController : UIViewController <DoneCancelNumberPadToolbarDelegate>
@property (weak, nonatomic) IBOutlet UITextField *inputExampleTextField;

ViewController

Attach the DoneCancelNumberPadToolbar to the textfield

- (void)viewDidLoad
{
    [super viewDidLoad];
    DoneCancelNumberPadToolbar *toolbar = [[DoneCancelNumberPadToolbar alloc] initWithTextField:inputExampleTextField];
    toolbar.delegate = self;
    inputExampleTextField.inputAccessoryView = toolbar;
}

Use the delegate methods as needed

-(void)doneCancelNumberPadToolbarDelegate:(DoneCancelNumberPadToolbar *)controller didClickDone:(UITextField *)textField
{
    NSLog(@"%@", textField.text);
}

-(void)doneCancelNumberPadToolbarDelegate:(DoneCancelNumberPadToolbar *)controller didClickCancel:(UITextField *)textField
{
    NSLog(@"Canceled: %@", [textField description]);
}

http://timbroder.com/2012/08/adding-done-and-cancel-buttons-to-an-ios-number-pad.html

Something went wrong with that request. Please try again.