I subclassed UITextField and want to share this...
Make sure that you import the AudioToolBox framework!
And copy the sound file to your project.
The textField has to be of the type "NumberPad". Otherwise it will look weird.
This will also work with multiple textFields.
FKTextField.h:
Code:
#import
@interface FKTextField : UITextField {
}
-(void)addDot;
@end
FKTextField.m:
Code:
#import "FKTextField.h"
#import
@implementation FKTextField
- (void)becomeFirstResponder {
[super becomeFirstResponder];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(resignFirstResponder) name:UITextFieldTextDidEndEditingNotification object:self];
//The UIWindow that contains the keyboard view
UIWindow* tempWindow;
//Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
//UIKeyboard is a subclass of UIView anyways
UIView* keyboard;
//Check each window in our application
for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++)
{
//Get a reference of the current window
tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
//Get a reference of the current view
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:@"
It's not that much but I hope it will help someone.
edit:
Something is messed up with the second code block.
Quote me or download the files.