IOS8 numeric keypad plus left lower corner to complete button

Source: Internet
Author: User

The core code for the iOS8 numeric keypad plus the bottom left corner of the button 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:@ "finished" 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]; NSLog (@ "%@", [KeYboard description]); if ([[[Keyboard description] hasprefix:@ "<uiperipheralhostview"] = = YES) | | ([[Keyboard description] hasprefix:@ "<uikeyboard"] = = YES) | | ([[[Keyboard description] hasprefix:@ "<uiinputsetcontainerview"] = = YES))                {UIView *donebuttonview = [keyboard Viewwithtag:num_pad_done_button_tag];                if (Donebuttonview = = nil) {[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 inferred logic.

After 2.ios8. The size of the keyboard view becomes the size of the entire screen. So you need to adapt the location of the button.



Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

IOS8 numeric keypad plus left lower corner to complete 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.