I have UITextView subclass with no keyboard, that use buttons for input. I want to allow move cursor by tap to any position, not only to start or end of word. That's how it's works now:
That's what I want:
I think that solution for this problem is quite complex for beginner, so I ask you for a bit more detailed description how to do it.
I have found this but dont know where should I use this part of code.
Here is solution:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.nextResponder touchesBegan:touches withEvent:event];
UITouch *userTouch = [[event allTouches] anyObject];
CGPoint currentPos = [userTouch locationInView:self];
UITextPosition *cursorPosition=[self closestPositionToPoint:CGPointMake(currentPos.x, currentPos.y)];
[self setSelectedTextRange:[self textRangeFromPosition:cursorPosition toPosition:cursorPosition]];
}