objective c - adding custom button to number pad keyboard ios 6 -


i new in ios & using ios 6. have more 1 textfield in code, 1 of them uses number pad keyboard , want add custom button it.

i using code:

 uibutton *donebutton = [uibutton buttonwithtype:uibuttontypecustom];     donebutton.frame = cgrectmake(0, 163, 106, 53);     donebutton.adjustsimagewhenhighlighted = no;     [donebutton setimage:[uiimage imagenamed:@"doneup.png"] forstate:uicontrolstatenormal];     [donebutton setimage:[uiimage imagenamed:@"donedown.png"] forstate:uicontrolstatehighlighted];     [donebutton addtarget:self action:@selector(donebutton:) forcontrolevents:uicontroleventtouchupinside];      // locate keyboard view     uiwindow* tempwindow = [[[uiapplication sharedapplication] windows] objectatindex:1];     uiview* keyboard;     for(int i=0; i<[tempwindow.subviews count]; i++) {         keyboard = [tempwindow.subviews objectatindex:i];         // keyboard view found; add custom button         if([[keyboard description] hasprefix:@"<uiperipheralhost"] == true)             [keyboard addsubview:donebutton];       } 

selector called, problem [[tempwindow.subviews]count] 0.

could me ?

thanks in advance.

i have used following code. check it.

- (void)textfielddidbeginediting:(uitextfield *)textfield {     if(textfield==txt1)     {          [[nsnotificationcenter defaultcenter] addobserver: self                                                  selector: @selector(keyboarddidshoworhide:)                                                      name: uikeyboarddidshownotification object:nil];      }     else     {          [[nsnotificationcenter defaultcenter] removeobserver:self name:uikeyboarddidshownotification object:nil];     }    } - (void) keyboarddidshoworhide : (id) sender {     // create custom button     uibutton *donebutton = [uibutton buttonwithtype:uibuttontypecustom];     donebutton.frame = cgrectmake(0, 427, 106, 53);     donebutton.adjustsimagewhenhighlighted = no;     [donebutton setbackgroundimage:[uiimage imagenamed:@"doneup.png"] forstate:uicontrolstatenormal];     [donebutton setbackgroundimage:[uiimage imagenamed:@"donedown.png"] forstate:uicontrolstatehighlighted];     [donebutton addtarget:self action:@selector(donebutton:) forcontrolevents:uicontroleventtouchupinside];     uiwindow* tempwindow = [[[uiapplication sharedapplication] windows] objectatindex:1];     [tempwindow addsubview:donebutton];   } -(void)donebutton:(id)sender {     uibutton *btntmp=sender;     [btntmp removefromsuperview];     [[nsnotificationcenter defaultcenter] removeobserver:self name:uikeyboarddidshownotification object:nil];     //[self setviewmovedup:no];     [txt1 resignfirstresponder]; } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -