3

I'm trying to configure an UITextField for Right-To-Left writing. I Can't get it to work. The problem starts with the required UITextRange parameter for setBaseWritingDirection, I will always get nil as return value.

textfield.text = @"hello world";
UITextPosition * startpos =[textfield beginningOfDocument];  // returns nil! why?
UITextPosition *endpos =[textfield endOfDocument];           // returns nil

UITextRange* range =[textfield  textRangeFromPosition:startpos toPosition:endpos] ; // returns nil

[textfield setBaseWritingDirection:UITextWritingDirectionRightToLeft forRange:  range  ]; // does not work, range is nil

If I change the UItextField to an UITextView, the beginningOfDocument and endOfDocument method return a UITextPosition object.

Is that not implemented on UITextFields or am I doing something wrong?

tzer
  • 280
  • 4
  • 11

0 Answers0