Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dont show keyboard when textfield is tapped

I have a UITextField and a UIDatePicker in my XIB file, now I assigned the date that is chosen on the UIDatePicker to be the value of the text in my textfield. I've done this well, my only problem now is that I want the keyboard not to show when I tap on the textfield. I'm sure somebody knows the answer, I will be glad if you will share it :) Thanks!

btw. I tried this, but it didn't work..

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField resignFirstResponder];
}
like image 934
caribbean Avatar asked Nov 30 '22 20:11

caribbean


2 Answers

You can set delegate in your UITextField and return NO in textFieldShouldBeginEditing.

like image 22
Tarek Hallak Avatar answered Dec 21 '22 09:12

Tarek Hallak


Just set the UIDatePicker as the inputView of your UITextField.

This wil repalce the keyboard as the input view when the user clicks on the UItextField with the UIDatePicker.

self.dateTextField.inputView = self.datePicker;
like image 50
rckoenes Avatar answered Dec 21 '22 11:12

rckoenes