UITextView selection without becoming first responder
Previously the UITextView I added with IB could have text selected without having the keyboard appear. 开发者_如何学运维However suddenly without changing anything this is not the case, how can I force this behaviour again?
(The text view needs to be editable but not when the user double taps to select text, only when the caret is inserted or the user just taps on the textview)
NSRange selection = [yourTextView.text rangeOfString:yourTextView.text];
if( selection.location != NSNotFound ){ yourTextView.selectedRange = selection; }
This should do the trick for you.
I think it is very simple. just make textview editable false before selecting the text so that testview never get responder. and then use the above code to get selected text
精彩评论