0

I have taken a textField in a tableView. I want the user cant be able to edit the content of textField but can copy the contents.

I used the method textField.editing = false; but it also disable the copying feature.

Csq
  • 5,775
  • 6
  • 26
  • 39
user3792582
  • 41
  • 1
  • 1
  • 5
  • 3
    http://stackoverflow.com/questions/1920541/enable-copy-and-paste-on-uitextfield-without-making-it-editable – Retro Jul 01 '14 at 09:22

3 Answers3

1

Use textField:shouldChangeCharactersInRange:replacementString

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    return NO;
}

Don't forget to set your textfield's delegate.

tgyhlsb
  • 1,905
  • 14
  • 21
  • i also want keyboard dont pop up on its selection. I have made the textFields private to the cell so cant use resignFirstResponder in textfieldShoulReturn method.Any other way? – user3792582 Jul 01 '14 at 09:58
  • maybe [this](http://stackoverflow.com/questions/3175849/prevent-default-keyboard-from-showing-when-uitextfield-is-pressed) will work. Try it with myInputView=nil or a fake view – tgyhlsb Jul 01 '14 at 10:18
0

To disable editing in UITextField you need to return NO in delegate method

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    return NO;
}

or you can do this also To disable editing in UITextView set property editable to NO:

[textView setEditable:NO];
Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12
0

you can use this in viewwillappear method.

[textfield setEnable:NO];
gunas
  • 1,889
  • 1
  • 16
  • 29