Supreme aggravation with UITextField controls and the #@Q% return button
Supreme aggravation with UITextField controls and the #@Q% return button
- Subject: Supreme aggravation with UITextField controls and the #@Q% return button
- From: William Squires <email@hidden>
- Date: Mon, 04 Jul 2016 14:17:02 -0500
When making any iOS application project (Xcode 7.something, on 10.11.5, base SDK = iOS 9) that uses a UITextField control, I can't get the "return" button to work.
I've tried attaching an IBAction by Ctrl-dragging from the control to the .swift file for the view controller, naming the action, and selecting "Action" (instead of "outlet"), and it creates the action method as below:
@IBAction func textFieldDoneEditing(sender: UITextField) {
print("textFileDoneEditing:")
sender.resignFirstResponder()
}
I've verified that the connection is valid. Not only does the dot-in-a-circle show up to the left of the func, I can see that it's connected in the connections inspector pane. When I run (simulator or actual device) no output is logged to the console when the return key on the on-screen keyboard is tapped (clicked, in the case of the simulator.)
I also tried setting my view controller to implement UITextFieldDelegate
class ViewController : UIViewController , UITextFieldDelegate
{
...
func textFieldDidEndEditing(textField: UITextField) {
print("textFieldDidEndEditing:")
self.resignFirstResponder()
}
then went back to IB and the connections inspector pane. I then selected both of my UITextFields and made sure the delegate was connected to the proxy for the view controller (at the top of the "view controller" IB representation, to the left of the "File's Owner" and "Exit" proxies).
In neither case, does this work on either the simulator or device. Only once I tap on the other UITextField (set to have a numeric keypad) do both methods print to the console, by which time it's too late; the other text field already has the focus (first responder status.)
I don't know if this is an iOS bug, or an ID10T error (stupidity on my part). Please help!!
BTW, I also have two outlets to the UITextFields in question, one named "nameField" and one named "numberField". The first has the "default" keyboard, and the 2nd has the "numpad" keyboard; it's the first one that has the non-responsive "return" button (since a numpad keyboard doesn't have a "return" button - a sad oversight, IMHO)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden