本文介绍了我无法在Swift iOS中创建UIResponder nextResponder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASTextField类,它在UITextField之后扩展,我想定义textFieldResponder。

I have a class ASTextField which extends after UITextField and I want to define textFieldResponder.

是否有任何解决方案在Swift中写入以下行?

Is any solution to write below line in Swift ??

UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];

这是用Objective-C编写的?

which has been written in Objective-C below?

-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
  NSInteger nextTag = textField.tag + 1;
  // Try to find next responder
  UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
  if (nextResponder) {
    // Found next responder, so set it.
    [nextResponder becomeFirstResponder];
  } else {
    // Not found, so remove keyboard.
    [textField resignFirstResponder];
  }
  return NO; // We do not want UITextField to insert line-breaks.
}


推荐答案

这将是这样的

让nextResponder = textField.superview?.viewWithTag(nextTag)作为UIResponder!

希望它有所帮助!

这篇关于我无法在Swift iOS中创建UIResponder nextResponder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:09