Tuesday, January 29, 2013

Custom KeyBoard Handler With Done, Next and Previous Button



Keyword: Safari like keyboard, done, next button, tab orderring, text field, text field delegate

Custom KeyBoard Handler With Done, Next and Previous Button

Get contacts of all your emergency needs on single tap. Download Quick-Finder for iPhone


Get the sample code and helper file from the link

1) Copy helper files customKeyBoardHelper.h and customKeyBoardHelper.m to your project.
2) Follwing methods are provided in helper classes

  -(void)showingKeyboardHeader:(BOOL)isKeyboard;
  -(void)showingDoneButton:(BOOL)isDone;
  -(void)settingTitleForDoneButton:(NSString *)done WithImage:(UIImage *)dimg;


  -(void)addButtonWithTitle:(NSString *)tit forCustomHandler:(SEL)sel;
  -(void)addButtonWithImage:(UIImage *)img forCustomHandler:(SEL)sel;


  -(void)addButtonWithTitle:(NSString *)tit forEvent:(events)sel;
  -(void)addButtonWithImage:(UIImage *)img forEvent:(events)sel;


  -(void)addTextField:(UITextField *)txtField;
  -(void)getCustomeKeyBoard;
  -(id)initWithBaseController:(UIViewController *)ctrl;



Use of Helper Classes


1) Take a project of name KeyBoardSample.

2) Open KeyBoardSample.xib and populate 4 text fields on it. 

3) Named these as txt1,txt2,txt3 and txt4.

4) Connect all text fields outlets to .h File.

5) import customKeyBoardHelper.h to KeyBoardSample.h

5) Open .m file and modified the code of  viewDidLoad as 


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    customKeyBoardHelper *helper=[[customKeyBoardHelper alloc]initWithBaseController:self];
    [helper addTextField:self.txt1];
    [helper addTextField:self.txt3];
    [helper addTextField:self.txt2];

//  Here tab order is txt1 --> txt3 --> txt2 . You can change it.

    [helper addButtonWithTitle:@"Next" forEvent:MoveToNext];

// Two methods are provided. MoveToNext and MoveToBack
//  MoveToNext method is used to move cursor from one text field to next field.
//  MoveToBack method is used to move cursor from one text field to previous field.

   [helper addButtonWithTitle:@"Test" forCustomHandler:@selector(testtask)];

// You can also make your custom handler. Here we have made a method named testtask. We need to implement this method later.

// You can also set the image instead of giving title as 

 [helper addButtonWithImage:[UIImage imageNamed:@"imageName.png"forEvent:MoveToNext];
   
// Finally call the method to set your custom key board.   
    [helper getCustomeKeyBoard];
}


6) implement testtask method.

-(void)testtask
{



}

7) Done button is provided by default. You can hide this by using method showingDoneButton.


Get the sample code and helper files at   
http://adf.ly/IArVQ









No comments:

Post a Comment

Post a Comment