Recently encountered a problem in the project. On the setting page, there are two input boxes. When you want to press the box, the date control is displayed, and you can select the date and time. Baidu once and finds that there is no complete solution. Now, let's share it. You can use the inputview and inputAccessoryView attributes of textfield. Create a datePicker and assign the inputview attribute to two textfields. Create a toolbar that contains a Done button and assign it to the inputAccessoryView attribute. You need to use this Done to exit the inputview. Done event processing: if ([textField1 isFirstResponder]) {[textField1 resignFirstResponder];} else if ([textField2 isFirstResponder]) {[textField2 resignFirstResponder];} Example @ interface reply: NSObject <UIApplicationDelegate> {... @ property (nonatomic, retain) IBOutlet UIWindow * window; @ property (nonatomic, retain) IBOutlet UITextField * textField; @ property (nonatomic, retain) IB Outlet UIToolbar * accessoryView; @ property (nonatomic, retain) IBOutlet UIDatePicker * customInput;-(IBAction) dateChanged :( id) sender;-(IBAction) doneEditing :( id) sender; @ end in the XIB file, drag a UIToolbar and a UIDatePicker, but do not attach it to the View (drag it out of the View ). Connect to Outlets as appropriate. DateChanged: responds to the ValueChanges and doneEditing of datepicker. It is called when the Done button in the ToolBar is clicked (Connection-> Sent Actions-> selectors ). Implementation: @ implementation CustomKeyboardAppDelegate @ synthesize window = _ window; @ synthesize textField = _ textField; @ synthesize accessoryView = _ accessoryView; @ synthesize customInput = _ customInput;-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {self. textField. inputView = self. customInput; self. textField. inputAccessoryView = self. accessoryView ;...}... -(IBAction) dateChanged :( id) sender {UIDatePicker * picker = (UIDatePicker *) sender; self. textField. text = [NSString stringWithFormat: @ "% @", picker. date];}-(IBAction) doneEditing :( id) sender {[self. textField resignFirstResponder];} @ end