3
votes

I´ve looked at the monotouch samples and tried:

var range = new NSRange(selectionStart, 1);
NumberTextField.SelectedTextRange = IndexedRange.GetRange(range);

But this causes this exception at runtime: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[iOS_IndexedRange asRange]: unrecognized selector sent to instance 0x7d9bd690

I also looked at a lot of objective-c versions but i cant figure out how to do them on monotouch.

1

1 Answers

2
votes

Ruben Macias over at the Xamarin forums helped me.

entryField.BecomeFirstResponder();
var indexToSet = 3; //set cursor after the 3rd letter
var positionToSet = entryField.GetPosition(entryField.BeginningOfDocument, indexToSet);
entryField.SelectedTextRange = entryField.GetTextRange(positionToSet, positionToSet);