Tag: resignfirstresponder

自动在Swift中的文本字段中分配和分配第一个响应者

我已经采取了3个文本字段,并希望他们只持有一个整数OTP的目的(这是项目devise的需要)。 当用户在第一个文本字段中input数字时,应答者应自动分配到第二个文本字段,然后到第三个文本字段。 一旦用户在第三个文本框中input了最后一个OTP数字,我想要打开web服务。 我到目前为止所做的是: class ActivationCodeVC: UIViewController, UITextFieldDelegate 然后 otpField1.delegate = self otpField2.delegate = self otpField3.delegate = self 然后 func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { let text=textField.text let counter = text?.characters.count if counter >= 1 { if textField == otpField1{ otpField2.becomeFirstResponder() } else if textField == otpField2{ otpField3.becomeFirstResponder() } […]

为什么UITextField在resignFirstResponder上animation?

从iOS 8开始,表单中的UITextFieldsperformance得非常奇怪。 如果我点击另一个文本字段或按键盘上的Tab键,input的文字向上animation,然后迅速重新出现。 每次在视图加载之后,每隔一段时间就会发生。 它看起来像这样: 我的代码如下所示: #pragma mark – <UITextFieldDelegate> – (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.passwordTextField) { [self loginButtonClicked:nil]; } else if (textField == self.emailTextField) { [self.passwordTextField becomeFirstResponder]; } return YES; } 编辑: 看起来像这个问题是由我的键盘监听器引起的: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; – (void)keyboardWillHide:(NSNotification *)sender { self.loginBoxBottomLayoutConstraint.constant = 0; […]

resignFirstResponder不工作?

我试图在iPad上隐藏键盘,但我不知道为什么resignFirstResponder不起作用。 但是popToRoot运行良好。 – (BOOL)textFieldShouldReturn:(UITextField *)textField { NSString *desc = [NSString stringWithFormat:@"%@",[descTF text]]; [textField resignFirstResponder]; [self.navigationController popToRootViewControllerAnimated:YES]; return YES; } 那么你能指导我该怎么做?

为多个UITextFields分配第一个响应者

有一个应用程序,我在其中dynamic生成多个UITextFields 。 只要UITextFields没有被选中(触摸UITextField外部),我想要退出第一响应者。 我怎么能知道哪个UITextField我不得不辞职急救员? 请指定“标签”概念以外的任何其他方式,因为我已经尝试过了。 请build议正确的方向。 提前致谢。

使用UITextField理解resignFirstResponder

我试图摆脱键盘时,用户触摸我的UITextField外,通过使用此方法: – (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [mainTextController resignFirstResponder]; [super touchesBegan:touches withEvent:event]; } 但是,这似乎调用了按下键盘上的返回button后调用的方法,但我只是希望键盘消失,而不是按回报给我。 我怎么能做到这一点? 谢谢! 编辑:tGilani的答案是最直接的方式,就像一个魅力,没有改变UIControl。 但我猜Jonkroll的答案也适用。

IOS 7 UITextField resignFirstResponder BAD

我得到一个崩溃,当使用一个UItextField,在我的customCell,当我resignFirstResponder文本字段,但它不再可见(表视图滚动窗口)。 我仍然可以find文本字段,指针可以继续访问,它不是空的,崩溃只发生在IOS7 IOS6我没有这个问题。 下面是一些代码: textField是一个全局variables。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString * CellIdentifier = [NSString stringWithFormat:@"Cell%d",indexPath.row]; TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[TableCell alloc] init]; if(indexPath.row == 0) { [textField setFrame:CGRectMake(15, 5, cell.frame.size.width-60, cell.frame.size.height)]; textField.textAlignment = NSTextAlignmentLeft; [textField setBorderStyle:UITextBorderStyleNone]; textField.textColor = [UIColor blackColor]; textField.tag = indexPath.row; textField.delegate […]

键盘没有响应resignFirstResponder

当selecttextField(我的代码在底部)时,我不想显示键盘,而想显示popup视图。 如果键盘没有显示,那么一切正常。 但是,如果键盘显示,然后select文本字段键盘不会被解雇,某个地方firstResponders必须迷路,但我不知道在哪里。 有没有人有这个解决scheme? 我的文本框: self.startDateTextField = [[UITextField alloc] initWithFrame:CGRectMake(79, 148, 138, 27)]; [self.startDateTextField setBorderStyle:UITextBorderStyleRoundedRect]; [self.startDateTextField setDelegate:delegate]; [self.startDateTextField addTarget:delegate action:@selector(editStartDate:) forControlEvents:UIControlEventEditingDidBegin]; [popoverWrapper addSubview:self.startDateTextField]; 并在editStartDate:我有: -(void)editStartDate:(UITextField *)textField { [textField resignFirstResponder]; DatePickerVC *datePickerVC = [[DatePickerVC alloc] init]; datePickerVC.delegate = self; self.popoverController = [[UIPopoverController alloc] initWithContentViewController:datePickerVC]; [self.popoverController setDelegate:self]; [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 5, 5) inView:textField permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; }

UITextField的键盘不会消失。 不完全是

我有一个模式表单(iPad)的表格视图,其中一个单元格包含一个UITextField。 我的视图控制器持有对文本字段的引用,也是它的代表。 当文本字段命中返回时,我将它告诉-textFieldShouldReturn:的-textFieldShouldReturn: 。 在另一种情况下,我想迫使它结束编辑,所以我告诉整个表视图到-endEditing:YES 。 之后,我释放我的本地引用到文本字段,并重新加载行以replace其他东西。 在任何情况下键盘都不会消失。 我不知道什么是错,我不知道如何进一步debugging。 我从来没有遇到任何其他的文本编辑粘性键盘问题 – 第一个响应的辞职一直performance如预期。 有什么想法吗? 谢谢。