3

How to hide/disable keyboard ,if the textview editing is enabled.

I only want to that user can only be able to select the text and can't be allowed for entering text.

Because selected text will be converted in to image for move animation.

User will not be allowed for entering any text in textview so that's why keyboard should be hidden or disable ,he will be allowed only for text selection.

iosDev
  • 604
  • 3
  • 12
  • 28

5 Answers5

4

uitextview.editable = NO; or set checkmark in IB. It will allow to select text with options - Copy and Select All without keyboard appearing. Tap on the word and hold to select text.

beryllium
  • 29,669
  • 15
  • 106
  • 125
  • when i am doing this .......first time text section works fine ...but when i try to select text for second time it is giving below exception. 'NSRangeException', reason: '*** -[NSCFString substringWithRange:]: Range or index out of bounds' – iosDev Apr 11 '12 at 12:22
3

ok just uncheck the behavior of you UItextview in .xib file.

freelancer
  • 1,658
  • 1
  • 16
  • 37
1

Something to try it the 'editable' setting doesn't work out is to create a UIView that's hidden and out of the way somewhere and assign it as the inputView for the text view. If that property is non-nil, the view it contains will be shown instead of the keyboard.

Such as:

self.textView.inputView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)] autorelease];
Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • no.......still showing keyboard.... - (void)textViewDidChangeSelection:(UITextView *)textView { self.tv.inputView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; NSRange range = [tv selectedRange]; str = [tv.text substringWithRange:range];} – iosDev Apr 11 '12 at 12:44
0

try this

yourtextview.UserinterationEnable=No;

freelancer
  • 1,658
  • 1
  • 16
  • 37
0

This will make the keyboard disappear:

[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

This what you want to do?

jhavatar
  • 3,236
  • 1
  • 18
  • 11
  • when i am using this it is throwing exception..'NSRangeException', reason: '*** -[NSCFString substringWithRange:]: Range or index out of bounds' – iosDev Apr 11 '12 at 12:12