I have a class ASTextField which extends after UITextField and I want to define textFieldResponder.
Is any solution to write below line in Swift ??
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
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.
}
it will be something like this
let nextResponder = textField.superview?.viewWithTag(nextTag) as UIResponder!
Hope it helps!
来源:https://stackoverflow.com/questions/26510110/i-cant-create-uiresponder-nextresponder-in-swift-ios