iOS – Add UIButton to UIDATEPICKER

I have a UITextField, I set the inputView to UIDatePicker so that when I press UITextField instead of the keyboard, the UIDatePicker will pop up. I also want to add a “Next “Button on the toolbar so that the user can easily jump to the next field, but I don’t know how to do this because I have changed the view on the UITextField to get the UIDatePicker. The following is the code used when loading the view:

- (void)viewDidLoad
{
self.datePicker = [[UIDatePicker alloc] init];
self.datePicker.datePickerMode = UIDatePickerModeDate;
[self.datePicker addTarget:self action:@selector(datePickerValueChanged) forControlEvents:UIControlEventValueChanged];
issue.inputView = self.datePicker;
}

What are the suggestions for adding the “Next” button to the top of the toolbar?

Create a view to use as inputAccessoryView for text fields. This view should contain your buttons (e.g. , Next step, cancel, previous page).

I have a UITextField, and I set the inputView to UIDatePicker so that when I press UITextField instead of the keyboard, the UIDatePicker will pop up. I also I want to add a toolbar with a “Next” button on it so that the user can easily jump to the next field, but I don’t know how to do this because I have changed the view on the UITextField to get the UIDatePicker. The following is the code used when loading the view:

- (void)viewDidLoad
{
self.datePicker = [[UIDatePicker alloc] init ];
self.datePicker.datePickerMode = UIDatePickerModeDate;
[self.datePicker addTarget:self action:@selector(datePickerValueChanged) forControlEvents:UIControlEventValueChanged];
issue.inputView = self.datePicker;< br />}

What is the suggestion for adding the “Next” button to the top of the toolbar?

Create a view to use as an inputAccessoryView for a text field. This view should contain your buttons (e.g., next, cancel, previous page). < /p>

Leave a Comment

Your email address will not be published.