Sunday, June 2, 2013

UITextField inputView example in Objective C (iOS).

UITextField inputView

The custom input view to display when the text field becomes the first responder.

@property (readwrite, retain) UIView *inputView

Discussion of [UITextField inputView]
If the value in this property is nil, the text field displays the standard system keyboard when it becomes first responder. Assigning a custom view to this property causes that view to be presented instead.

The default value of this property is nil.

UITextField inputView example.
-(void)viewDidLoad {
self.svScrollViewM.contentSize = CGSizeMake(320, 416);
[self registerForEditingEvents:amplitude1];
[self registerForEditingEvents:rate1];
[self registerForEditingEvents:pulse_width1];
[self registerForEditingEvents:impedance1];

UIPickerView *modePicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
modePicker.tag = MyModePicker;
modePicker.delegate = self;
modePicker.dataSource = self;
[modePicker setShowsSelectionIndicator:YES];
configuration.inputView = modePicker;
[modePicker release];

[super viewDidLoad];

    //Prepare data for pickers
    mode = [NSArray arrayWithObjects:@"Voltage",@"Current",nil];

[mode retain];

//mode = [[NSMutableArray alloc] init];
//[mode addObject]

Example of [UITextField inputView].
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    picker = [[UIPickerView alloc] initWithFrame:CGRectZero];
    return YES;

UITextField inputView example.
textField.inputView = wView;

End of UITextField inputView example article.