0

I have a text view. I have not implemented the UITextView Delegate Protocol in my .h, but in .m file I am overriding the delegate methods (shouldBeginEditing and endEditing) and the methods are getting called. Now, what I want to do is whenever user clicks on text view, I always want to position the cursor at the beginning (no matter where he clicks on the text view). I have tried using this lines in textview's BeginEditing method, but it was of no use.

[textView setSelectedRange:NSMakeRange(0, 0)];

I always want to allow user to enter new text at the beginning (don't want the text at the end of already entered text view's text). Someone pls tell me how to get rid of this problem?

PS: I working on ios , xcode 4.2....

anshul
  • 846
  • 1
  • 14
  • 32
  • Hey found the answer at this link: [Moving the cursor to the beginning of UITextField](http://stackoverflow.com/questions/4180263/moving-the-cursor-to-the-beginning-of-uitextfield) – anshul Mar 03 '12 at 07:34

1 Answers1

0
UITextView*textView;
[textView setContentOffset:CGPointMake(0, 0) animated:YES];
Vikram
  • 8,235
  • 33
  • 47
  • thanx vikram, but will it position the cursor at the beginning of the text view text, no matter where I click on text view..... I think this is for moving the text from the borders of the text view, not for changing the cursor position. – anshul Feb 29 '12 at 07:12
  • this may give you additional info: http://stackoverflow.com/questions/8194712/ios-how-to-move-cursor-to-the-beginning-of-the-current-line-in-uitextview – Vikram Feb 29 '12 at 07:17