views:

16

answers:

1

How to implement the move leftward like pressing the left button on the physical keyboard in iPad?

I can get the current cursor position, but I need to figure out a way to calculate the width of the current character and subtract that from the current x position.

Is there anyway to calculate the width of the current character? Thanks!

+1  A: 

I don't think you need to calculate the width of the current character if you want to move a cursor in UITextView. UITextView has a property called selectedRange that gives the current position and selected range of the cursor in UITextView. You just have to assign a new range value into your UITextView's selectedRange property. For example,

textView.selectedRange = NSMakeRange(textView.selectedRange.location - 1, 0); 
kyu