I have this code, who capture when the user click in my textfield, and call a function:
-(void)viewDidLoad{
[mytextfield addTarget:self
action:@selector(callvariant:)
forControlEvents:UIControlEventTouchDown];
}
-(void)callvariant:(UITextField *)textField{
NovoProdutoMFViewController *mf = [[NovoProdutoMFViewController alloc] init];
[self.navigationController pushViewController:mf animated:YES];
[mf setBusca:textField.placeholder];
}
The code works perfectly, but recently had the need to put a UIScrollView in my project with this code:
-(void)viewDidLoad{
[mytextfield addTarget:self
action:@selector(callvariant:)
forControlEvents:UIControlEventTouchDown];
scroll.contentSize = scroll.frame.size;
scroll.frame = self.view.frame;
[self.view addSubview:scroll];
}
-(void)callvariant:(UITextField *)textField{
NovoProdutoMFViewController *mf = [[NovoProdutoMFViewController alloc] init];
[self.navigationController pushViewController:mf animated:YES];
[mf setBusca:textField.placeholder];
}
Now Sometimes when the user click on textfield call the function and sometimes not call, and at other times it is necessary to keep the text field clicked down for more than 2 seconds to call the function and has sometimes this method does not work.
I do not know what might be happening, but how can I solve this?