Adding TabGestureRecognizer to TextField
up vote
0
down vote
favorite
All my UiTextFields are created programmatically so i can't just right-click-pull-over the onTab function to the swift file.
I tried to add a gesture recognizer to the text field, but now I have to DOUBLE-click so clickTextField() is triggered.
// make clickable
let clickName = MyTapGesture(target: self, action: #selector(ViewMain.clickTextField(_:)))
clickName.count_of_selection = String(i)
self.finishName[i].addGestureRecognizer(clickName)
How can I make it so that this works with one click. A different approach maybe?
swift xcode uitextfield
add a comment |
up vote
0
down vote
favorite
All my UiTextFields are created programmatically so i can't just right-click-pull-over the onTab function to the swift file.
I tried to add a gesture recognizer to the text field, but now I have to DOUBLE-click so clickTextField() is triggered.
// make clickable
let clickName = MyTapGesture(target: self, action: #selector(ViewMain.clickTextField(_:)))
clickName.count_of_selection = String(i)
self.finishName[i].addGestureRecognizer(clickName)
How can I make it so that this works with one click. A different approach maybe?
swift xcode uitextfield
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
All my UiTextFields are created programmatically so i can't just right-click-pull-over the onTab function to the swift file.
I tried to add a gesture recognizer to the text field, but now I have to DOUBLE-click so clickTextField() is triggered.
// make clickable
let clickName = MyTapGesture(target: self, action: #selector(ViewMain.clickTextField(_:)))
clickName.count_of_selection = String(i)
self.finishName[i].addGestureRecognizer(clickName)
How can I make it so that this works with one click. A different approach maybe?
swift xcode uitextfield
All my UiTextFields are created programmatically so i can't just right-click-pull-over the onTab function to the swift file.
I tried to add a gesture recognizer to the text field, but now I have to DOUBLE-click so clickTextField() is triggered.
// make clickable
let clickName = MyTapGesture(target: self, action: #selector(ViewMain.clickTextField(_:)))
clickName.count_of_selection = String(i)
self.finishName[i].addGestureRecognizer(clickName)
How can I make it so that this works with one click. A different approach maybe?
swift xcode uitextfield
swift xcode uitextfield
asked 9 hours ago
Martin Vidic
138119
138119
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
UITextField
has a tap gesture. You need to use it's delegate methods:
func textFieldShouldBeginEditing(_ textField: UITextField)
func textFieldDidEndEditing(_ textField: UITextField)
func textFieldShouldEndEditing(_ textField: UITextField)
func textFieldDidBeginEditing(_ textField: UITextField)
func textFielShouldClear(_ textField: UITextField)
func textFielShouldReturn(_ textField: UITextField)
Do not forget
yourTextField.delegate = self
after you create an extension for you vc:
extension ViewController: UITextFieldDelegate {
// here you add the necessary delegate methods for your textFields
}
Note: You do not need to implement every method. Use only the one you need. More details can be found on AppleDeleveloper .
New contributor
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
UITextField
has a tap gesture. You need to use it's delegate methods:
func textFieldShouldBeginEditing(_ textField: UITextField)
func textFieldDidEndEditing(_ textField: UITextField)
func textFieldShouldEndEditing(_ textField: UITextField)
func textFieldDidBeginEditing(_ textField: UITextField)
func textFielShouldClear(_ textField: UITextField)
func textFielShouldReturn(_ textField: UITextField)
Do not forget
yourTextField.delegate = self
after you create an extension for you vc:
extension ViewController: UITextFieldDelegate {
// here you add the necessary delegate methods for your textFields
}
Note: You do not need to implement every method. Use only the one you need. More details can be found on AppleDeleveloper .
New contributor
add a comment |
up vote
0
down vote
UITextField
has a tap gesture. You need to use it's delegate methods:
func textFieldShouldBeginEditing(_ textField: UITextField)
func textFieldDidEndEditing(_ textField: UITextField)
func textFieldShouldEndEditing(_ textField: UITextField)
func textFieldDidBeginEditing(_ textField: UITextField)
func textFielShouldClear(_ textField: UITextField)
func textFielShouldReturn(_ textField: UITextField)
Do not forget
yourTextField.delegate = self
after you create an extension for you vc:
extension ViewController: UITextFieldDelegate {
// here you add the necessary delegate methods for your textFields
}
Note: You do not need to implement every method. Use only the one you need. More details can be found on AppleDeleveloper .
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
UITextField
has a tap gesture. You need to use it's delegate methods:
func textFieldShouldBeginEditing(_ textField: UITextField)
func textFieldDidEndEditing(_ textField: UITextField)
func textFieldShouldEndEditing(_ textField: UITextField)
func textFieldDidBeginEditing(_ textField: UITextField)
func textFielShouldClear(_ textField: UITextField)
func textFielShouldReturn(_ textField: UITextField)
Do not forget
yourTextField.delegate = self
after you create an extension for you vc:
extension ViewController: UITextFieldDelegate {
// here you add the necessary delegate methods for your textFields
}
Note: You do not need to implement every method. Use only the one you need. More details can be found on AppleDeleveloper .
New contributor
UITextField
has a tap gesture. You need to use it's delegate methods:
func textFieldShouldBeginEditing(_ textField: UITextField)
func textFieldDidEndEditing(_ textField: UITextField)
func textFieldShouldEndEditing(_ textField: UITextField)
func textFieldDidBeginEditing(_ textField: UITextField)
func textFielShouldClear(_ textField: UITextField)
func textFielShouldReturn(_ textField: UITextField)
Do not forget
yourTextField.delegate = self
after you create an extension for you vc:
extension ViewController: UITextFieldDelegate {
// here you add the necessary delegate methods for your textFields
}
Note: You do not need to implement every method. Use only the one you need. More details can be found on AppleDeleveloper .
New contributor
edited 8 hours ago
New contributor
answered 9 hours ago
Deryck Lucian
716
716
New contributor
New contributor
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400439%2fadding-tabgesturerecognizer-to-textfield%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown