开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜