How can we get selected text index in UITextView in IOS

gdkgdk INMember ✭✭✭

Hi everyone, I am struggle to find out the selected text index of a UITextView. In below pitcher I have select a some text and I am getting selected text but I want to know the that selected text index. Please give any idea. Thanks in advance.


  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Did you try UITextView.SelectedTextRange property?

  • gdkgdk INMember ✭✭✭

    Hi MihsMarkic, Thanks for spending time. I am actually try to get the index position not the text range otherwise is there way to get the index position from selected text range.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    The UITextView.SelectedTextRange property mentioned by Miha Markic would be the correct way. The UITextView.SelectedTextRange property is of type UITextRange, and a UITextRange has a Start and an End property, so textView.SelectedTextRange.Start should give you the index for where the selection starts,

Sign In or Register to comment.