IOS8 the lower left corner of the numeric keypad add the Finish button

Source: Internet
Author: User

IOS8 The core code of the Add complete button in the lower left corner of the numeric keypad is as follows:

-(void) adddonebuttontonumpadkeyboard{UIButton *donebutton = [UIButton buttonwithtype:uibuttontypecustom];    if (Systemversion < 8.0) {donebutton.frame = CGRectMake (0, 163, 106, 53);    }else{donebutton.frame = CGRectMake (0, screen_size.height-53, 106, 53);    } Donebutton.tag = Num_pad_done_button_tag;    donebutton.adjustsimagewhenhighlighted = NO;    [Donebutton settitle:@ "completed" forstate:uicontrolstatenormal];    [Donebutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal];        [Donebutton addtarget:self Action: @selector (Donebutton:) forcontrolevents:uicontroleventtouchupinside];    Nsarray *windowarr = [[UIApplication sharedapplication] windows];        if (Windowarr! = Nil && windowarr.count > 1) {UIWindow *needwindow = [Windowarr objectatindex:1];        UIView *keyboard;            for (int i = 0; i < [needwindow.subviews count]; i++) {keyboard = [needwindow.subviews objectatindex:i]; if ([[[Keyboard DEscription] hasprefix:@ "<uiperipheralhostview"] = = YES) | | ([[Keyboard description] hasprefix:@ "<uikeyboard"] = = YES) | | ([[[Keyboard description] hasprefix:@ "<uiinputsetcontainerview"] = = YES))                {if ([[Keyboard subviews] count] <= 1) {[Keyboard Addsubview:donebutton];    }}}}}-(void) removedonebuttonfromnumpadkeyboard{UIView *donebutton = nil;    Nsarray *windowarr = [[UIApplication sharedapplication] windows];        if (Windowarr! = Nil && windowarr.count > 1) {UIWindow *needwindow = [Windowarr objectatindex:1];        UIView *keyboard;            for (int i = 0; i < [needwindow.subviews count]; i++) {keyboard = [needwindow.subviews objectatindex:i]; if ([[[Keyboard description] hasprefix:@ "<uiperipheralhostview"] = = YES) | | ([[Keyboard description] hasprefix:@ "<uikeyboard"] = = YES) | | ([[[Keyboard description] hasprefix:@ "<uiinputsetcontainerview"] = = YES)) {               Donebutton = [keyboard Viewwithtag:num_pad_done_button_tag];                if (Donebutton! = nil) {[Donebutton Removefromsuperview]; }            }        }    }}

Note:

After 1.ios8, the description of the keyboard view changes to start with <uiinputsetcontainerview , so you need to add this to the logic of the judgment.

After 2.ios8, the size of the keyboard view becomes the size of the entire screen, so you need to fit the position that the button was added to.



IOS8 the lower left corner of the numeric keypad add the Finish button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.