Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is UIGestureRecognizer being called on my textField clear button?
    text
    copied!<p>I have a UITableView with a gesture recognizer added:</p> <pre><code>UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)]; [myTableView addGestureRecognizer:gestureRecognizer]; gestureRecognizer.cancelsTouchesInView = NO; </code></pre> <p>... everything works fine when tapping on the tableview to dismiss the keyboard. My problem is, my hideKeyboard method also calls when tapping on the "clear" button on my UITextField. Very strange.</p> <pre><code>commentTextField = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, 310, 35)]; commentTextField.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter; commentTextField.borderStyle = UITextBorderStyleRoundedRect; commentTextField.textColor = [UIColor blackColor]; //text color commentTextField.font = [UIFont fontWithName:@"Helvetica" size:14.0]; //font size commentTextField.placeholder = @"Enter a comment..."; //place holder commentTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support commentTextField.keyboardType = UIKeyboardTypeDefault; // type of the keyboard commentTextField.returnKeyType = UIReturnKeySend; // type of the return key commentTextField.clearButtonMode = UITextFieldViewModeAlways; // has a clear 'x' button to the right commentTextField.delegate = self; [commentTextField setHidden:NO]; [commentTextField setEnabled:YES]; [commentTextField setDelegate: self]; hide keyboard method: - (void) hideKeyboard{ if(keyboard){ [commentTextField resignFirstResponder]; [UIView animateWithDuration:.3 delay:.0 options:UIViewAnimationCurveEaseInOut animations:^{ // start animation block [myTableView setFrame:CGRectMake(0, myTableView.frame.origin.y + 216, myTableView.frame.size.width, myTableView.frame.size.height)]; } completion:^(BOOL finished){ }]; keyboard = 0; } } </code></pre> <p>Any help would be appreciated, thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload