ios9 - How to show “Done” button on iPhone number pad in ios 9 -


- (void)keyboardwillshow:(nsnotification *)note {     // create custom button     uibutton *donebutton = [uibutton buttonwithtype:uibuttontypecustom];     donebutton.frame = cgrectmake(0, 163, 106, 53);     donebutton.adjustsimagewhenhighlighted = no;     //[donebutton setimage:[uiimage imagenamed:@"donebuttonnormal.png"] forstate:uicontrolstatenormal];     //[donebutton setimage:[uiimage imagenamed:@"donebuttonpressed.png"] forstate:uicontrolstatehighlighted];     [donebutton settitle:@"完成" forstate:uicontrolstatenormal];     [donebutton settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal];     [donebutton addtarget:self action:@selector(donebutton:) forcontrolevents:uicontroleventtouchupinside];       uiview *foundkeyboard = nil;     uiwindow *keyboardwindow = nil;       keyboardwindow = [[[uiapplication sharedapplication] windows] lastobject] ;     keyboardwindow.userinteractionenabled = yes;     if (!keyboardwindow) return;      (__strong uiview *possiblekeyboard in [keyboardwindow subviews]) {          if ([[possiblekeyboard description] hasprefix:@"<uiinputsetcontainerview"]) {             (__strong uiview *possiblekeyboard_2 in possiblekeyboard.subviews) {                 if ([possiblekeyboard_2.description hasprefix:@"<uiinputsethostview"]) {                     foundkeyboard = possiblekeyboard_2;                 }             }         }     }       if (foundkeyboard) {         if ([[foundkeyboard subviews] indexofobject:donebutton] == nsnotfound) {             [foundkeyboard addsubview:donebutton];         } else {             [foundkeyboard bringsubviewtofront:donebutton];         }      }  } 

try may helped.

- (void)viewdidload     {         [super viewdidload];          uitoolbar* numbertoolbar = [[uitoolbar alloc]initwithframe:cgrectmake(0, 0, 320, 50)];         numbertoolbar.barstyle = uibarstyleblacktranslucent;         numbertoolbar.items = [nsarray arraywithobjects:                              [[uibarbuttonitem alloc]initwithtitle:@"cancel" style:uibarbuttonitemstylebordered target:self action:@selector(cancelnumberpad)],                              [[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil],                              [[uibarbuttonitem alloc]initwithtitle:@"apply" style:uibarbuttonitemstyledone target:self action:@selector(donewithnumberpad)],                          nil];         [numbertoolbar sizetofit];         numbertextfield.inputaccessoryview = numbertoolbar;     }      -(void)cancelnumberpad{         [numbertextfield resignfirstresponder];         numbertextfield.text = @"";     }      -(void)donewithnumberpad{         nsstring *numberfromthekeyboard = numbertextfield.text;         [numbertextfield resignfirstresponder];     } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -