我有这段代码,当用户点击我的文本字段时,它会捕获并调用一个函数:
-(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];
}
该代码完美运行,但最近需要使用以下代码在我的项目中放置一个 UIScrollView:
-(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];
}
现在有时候当用户点击textfield时调用函数,有时候不调用,而其他时候需要保持text field点击2秒以上才能调用函数,有时候这个方法不起作用。
我不知道会发生什么,但我该如何解决这个问题?