1

I want my UITextField to be editable from picker view but not selectable (I do not want copy,paste etc. options to be displayed). I achieved that it is editable from picker view but it is also selectable, which I don't want.

Is there a way to do so? Thanks :)

Emrah Akgül
  • 630
  • 2
  • 7
  • 18
  • 1
    http://stackoverflow.com/questions/1426731/how-disable-copy-cut-select-select-all-in-uitextview have a loot at this answer. you have to subclass the uitextfleld and implement this method. – Muhammad Zohaib Ehsan Mar 22 '16 at 07:10
  • 1
    https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingCopy,Cut,andPasteOperations/UsingCopy,Cut,andPasteOperations.html have a look at this also. – Muhammad Zohaib Ehsan Mar 22 '16 at 07:10
  • Problem is, it is text field, not text view. – Emrah Akgül Mar 22 '16 at 07:12
  • 1
    textfield also inherits from uiresponder :). So you can implement this method.this method i written in uiresponder. see https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/ – Muhammad Zohaib Ehsan Mar 22 '16 at 07:14
  • 1
    Thank you very much Muhammad! If only I could upvote more :) – Emrah Akgül Mar 22 '16 at 07:27

1 Answers1

0

set timeTextField.delegate = self

extension YourViewController: UITextFieldDelegate {

// For not allow user edit or cut
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
    textField.isUserInteractionEnabled = false;
    return true
}

func textFieldDidEndEditing(_ textField: UITextField) {
    textField.isUserInteractionEnabled = true;
}

}