admin管理员组文章数量:1400031
in a hybrid Objective-C project IQKeyboardManager handles all of the keyboard stuff in the Objective-C view controllers.
I have now created a Swift VC. The objective-C version of IQKeyboardManager is exposed in the bridging header. The VC is in a Storyboard, the class is set to the Swift class and there are outlets from the UIElements including the textfield that seem to be active to the Swift File.
However, the UITextFields in the Swift VC are completely unresponsive to touch. If you set the UITextField as first responder in code, you can type into it. However, once you stop typing and tap somewhere else on the keyboard, you can no longer type anything further in the UITextField and it is again inactive.
I have checked and no other views are blocking the textFields. The ViewController conforms to the UITextFieldDelegate. The delegates are set in code in ViewDidLoad.
One possibility is that maybe IQKeyboardManager is interfering. (Apparently there is a swift version of IQKeyboardManager but it is much heavier so I have not tried to include it.) However, Other UI elements, a button and a barbuttonitem are also inactive.
What might be the issue with these UIElements all being inactive? Here is some of the code that might be relevant:
Swift file:
@objcMembers class FotPasswordVC: UIViewController, UITextFieldDelegate, UIGestureRecognizerDelegate {
@IBOutlet weak var userName: UITextField!
@IBOutlet weak var emailAddress: UITextField!
@IBAction func sendButtonPressed(_ sender: Any) {
print("Send button was pressed")
}
@IBOutlet weak var sendButton: UIButton!
@IBAction func cancelAndDismiss(_ sender: Any) {
print("Close button pressed")
self.dismiss(animated: true, completion: nil)
}
//MARK: - LIFE CYCLE
public override func viewDidLoad() {
super.viewDidLoad()
sendButton.setTitle("Retrieve Password", for: .normal)
userName.placeholder = "Username"
emailAddress.placeholder = "Email address"
userName.becomeFirstResponder()
userName.isUserInteractionEnabled = true
emailAddress.isUserInteractionEnabled = true
userName.delegate = self //SET DELEGATE
emailAddress.delegate = self //SET DELEGATE
instructionsLabel.text = "Enter username and email"
sendButton.isEnabled = true
emailAddress.isEnabled = true
userName.isEnabled = true
}
本文标签:
版权声明:本文标题:keyboard - UITextField not responding except initially when set as first responder in Objective-CSwift hybrid project with IQKey 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744231905a2596377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论