IOS-custom keyboard Selector
Target style:
Directly run the Code:
Compliance Agreement
Implementation Method
// Create UITextField and set setInputAccessoryView to custom Toolbar and change the keyboard style to the keyboard selector-(void) creatTextField {UITextField * textField = [[UITextField alloc] initWithFrame: CGRectMake (10, 64, [UIScreen mainScreen]. bounds. size. width-20, 44)]; [textField setInputAccessoryView: self. kbToolbar]; // custom keyboard selector UIPickerView * pickerView = [[UIPickerView alloc] initWithFrame: CGRectMake (0, 50, kScreenWidth, 320)]; [pickerView setDataSource: self]; [pickerView setDelegate: self]; // select the indicator [pickerView setShowsSelectionIndicator: YES]; // custom keyboard type [self. sourceFD setInputView: pickerView]; [textField setInputView: pickerView]; [self. view addSubview: textField];}
Implement data source and proxy Methods
# Pragma mark-UIPickerViewDelegate and UIPickerViewDataSource // must be implemented // returns the number of 'columns 'to display.-> the total number of columns in the selector! -(NSInteger) numberOfComponentsInPickerView :( UIPickerView *) pickerView {return 1;} // returns the # of rows in each component ..-> specifies the number of rows in each column of the selector! -(NSInteger) pickerView :( UIPickerView *) pickerView partition :( NSInteger) component {return 5;} // selector each row name-(NSString *) pickerView :( UIPickerView *) pickerView titleForRow :( NSInteger) row forComponent :( NSInteger) component {if (row = 0) {return @ "RMB (RMB)";} else if (row = 1) {return @ "USD (USD)" ;}else if (row = 2) {return @ "GBP (GBP)" ;}else if (row = 3) {return @ "(JPY)";} else if (row = 4) {return @ "Euro (EUR)";} else {return @".. ";}}