iOS numeric keypad plus Finish button

Source: Internet
Author: User

The property of the text input box named Valuetextfield on 1.xib is changed to the following scenario

2. Socket variables

@property (Weak, nonatomic) Iboutlet Uitextfield *valuetextfield;

3. Cancellation of First Responder

-(void) numberfieldcancle{        [Self.valuetextfield resignfirstresponder];    }

3. Generate toolbar

-(Uitoolbar *) addtoolbar{        *toolbar = [[Uitoolbar alloc] Initwithframe:cgrectmake (00  - )]; //     uitoolbar *toolbar =[[uitoolbar alloc] init];    Uibarbuttonitem *bar = [[Uibarbuttonitem alloc] Initwithtitle:@ " done "  style: Uibarbuttonitemstyleplain target:self Action: @selector (Numberfieldcancle)];     = @[bar];         return toolbar;}

4. Add a button to the keyboard when the keyboard is raised

-(BOOL) textfieldshouldbeginediting: (Uitextfield *) textfield{    if (textfield==  Self.valuetextfield) {            Self.valueTextField.inputAccessoryView=[self addtoolbar];    }     return YES;}

5. Notice oh, this. m to comply with the uitextfielddelegate protocol

@interface Bnritemdetailviewcontroller () <UITextFieldDelegate>

iOS numeric keypad plus 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.