ios-define your own keyboard selector

Source: Internet
Author: User

Target style:

Directly on the code:
Compliance Agreement

<UIPickerViewDataSource,UIPickerViewDelegate>

Implementation method

//Create Uitextfield Settings Setinputaccessoryview define the toolbar for yourself and change the keyboard style to the keyboard selector-(void) creattextfield{Uitextfield *textfield = [[Uitextfield alloc] Initwithframe:cgrectmake (Ten, -, [UIScreen Mainscreen]. Bounds. Size. Width- -, -)]; [TextField Setinputaccessoryview: Self. Kbtoolbar];//define your own keyboard selectorUipickerview *pickerview = [[Uipickerview alloc] Initwithframe:cgrectmake (0, -, Kscreenwidth, the)]; [Pickerview Setdatasource: Self]; [Pickerview setdelegate: Self];//Select indicator[Pickerview Setshowsselectionindicator:YES];//keyboard type defined by itself[ Self. SOURCEFDSetinputview:pickerview];    [TextField Setinputview:pickerview]; [ Self. ViewAddsubview:textfield];}

Implementing data source and Proxy methods

#pragma mark-uipickerviewdelegate and Uipickerviewdatasource//Must be implemented//Returns the number of the ' columns ' to display--How many columns does the selector share!- (Nsinteger) Numberofcomponentsinpickerview: (Uipickerview *) pickerview{return 1;}//Returns the # of rows in each component: how many rows are there in the selector column ?- (Nsinteger) Pickerview: (Uipickerview *) Pickerview numberofrowsincomponent: (Nsinteger) component{return 5;}//selector per row name-(NSString*) Pickerview: (Uipickerview *) Pickerview Titleforrow: (Nsinteger) Row forcomponent: (Nsinteger) component{if(Row = =0) {return@"Renminbi (RMB)"; }Else if(Row = =1){return@"United States dollar (USD)"; }Else if(Row = =2){return@"GBP (GBP)"; }Else if(Row = =3){return@"Japanese yen (JPY)"; }Else if(Row = =4){return@"euro (EUR)"; }Else{return@".."; }}

ios-define your own keyboard selector

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.