user3603583
user3603583

Reputation: 33

UIKeyboardWillShowNotification coming when input view for textfield is different

I am using date picker as input view for textfield. In view will appear I have added UIKeyboardWillShowNotification.

My problem is that when the date picker is to be seen then also it comes KeyboardWillShowNotification method. How can I differentiate that keyboard is seen or date picker is seen, as I need to resize table view according to that

I have assigned inputview in textfieldDidBeginEditing

cell.txtField.inputView = datePicker; 

Upvotes: 2

Views: 650

Answers (1)

user3655554
user3655554

Reputation: 26

you can implement the (BOOL)textFieldShouldBeginEditing:(UITextField *)textField delegate and then save a local variable that you are editing your textfield at the moment like

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
   self.editingTextfield = YES;
}

and in your (BOOL)textFieldShouldEndEditing:(UITextField *)textField you set that flag to false

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField {
   self.editingTextfield = NO;
}

in your KeyboardWillShowNotification notification you can check that flag to see which control issued the keyboard

Upvotes: 1

Related Questions