I have a tableviewcell and three text fields inside. I press a fist (called "target") and enter some number. A keyboard is displayed, which can be canceled by clicking the Finish button on the keyboard itself (resignFirstResponder () is attached to the Finish button).
When I try to edit a second text field (called "relevant") without firing the keyboard, the cursor does not appear the first time I touch the text field, which means that editing did not start (image 1 below). I need to touch this text box a second time until the cursor appears (image 2 below).
How can I get the cursor to appear the first time I touch the second text edit field?
And I do not want to hide my keyboard (running resignFirstResponder ()), when the user decides to continue typing, let him say 4-5 fields in a row. Therefore, editing in a text field should end and begin when the user deletes another text field. He edits all the text fields he needs, and then clicks Finish on the keyboard at the end.
(In fact, the cursor in the second text box appears with the first click if the user tapped the first text box, but added nothing)
My code is:
I select / blend the border of the edit text box:
func textFieldShouldBeginEditing(textField: UITextField) -> Bool
{
textField.layer.borderWidth = 1
textField.layer.cornerRadius = 2
textField.layer.borderColor = UIColor.blueColor().CGColor
return true
}
func textFieldShouldEndEditing(textField: UITextField) -> Bool
{
textField.layer.borderWidth = 1
textField.layer.borderColor = UIColor.clearColor().CGColor
return true
}
I assign the text before entering a variable, which I check later to prevent data processing if the user has not changed the text:
func textFieldDidBeginEditing(textField: UITextField) // remember number before user input to prevent actions when no input
{
textInEditField = textField.text!
}
func textFieldDidEndEditing(textField: UITextField)
{
if textField.text == textInEditField // no actions if field is empty or text is not changed
{
return
}
… inputed text processing
}
What I tried:
tourchesBegan. ,
scrollview,
override func touchesBegan(touches: Set<UITouch>, withEvent event:
UIEvent?)
{
self.view.endEditing(true)
}
textField.resignFirstResponder()
textFieldDidEndEditing(). , ,
, ,
, .
- ,
.
, .
, UITableView
[ ] [2] [2]: http://i.stack.imgur. /A 4voz.png [ ] [3] [3]: http://i.stack.imgur.com/l82A5.png