Kabali Kabali - 3 months ago 22
Objective-C Question

Set hidden textField on Tap gesture

Hide and show textField on tap gesture.

Here is code :

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ShowBASEURL)];
tap.numberOfTapsRequired = 3;
[_txtBaseUrl addGestureRecognizer:tap];

- (void)ShowBASEURL
{
_txtBaseUrl.hidden = NO;
}


- (void)textFieldShouldEndEditing:(UITextField *)textField
{
_txtBaseUrl.hidden = YES;
}


It's not working because after hiding textField, the tap gesture is not working.
Is there any other way to do it ?

Answer

you are hiding _txtBaseUrl instance. User Interaction will be disable at that time.Gesture will not work.

change this line and try

[_txtBaseUrl addGestureRecognizer:tap];

to

[self.view addGestureRecognizer:tap];

check your delegate method you assign as wrong

- (void)textFieldDidEndEditing:(UITextField *)textField
{
_txtBaseUrl.hidden = YES;

}
Comments