Reputation: 69
I want to know which delegate method will get fired when we long press the UITextfield or UITextview to move the cursor? Please help me out.
Upvotes: 0
Views: 1453
Reputation: 6067
You should use the Gesture Recognizer for this purpose
1)Firstly Add Recognizer to your TextFiled
**-(void)viewDidLoad{**
UILongPressGestureRecognizer *recognizerTextFiled = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandlerGurmukhiFirstSearch:)];
recognizerTextFiled.minimumPressDuration = 0.5;
//after this time Recognizer will invoke
// here i have added the Recognizer to that textField
// myTextFiled is a textField at which we want to detect the cursor movement
[myTextFiled addGestureRecognizer:recognizerTextFiled];
[recognizerTextFiled release];
}
2) You may Write Your Logic after detecting the Cursor Movement As Below
**-(void)longPressHandlerGurmukhiFirstSearch:(UILongPressGestureRecognizer *)gestureRecognizer**
{
if(UIGestureRecognizerStateBegan ==gestureRecognizer.state)
{
// you can write the code here as you want for moving the Cursor
}
if(UIGestureRecognizerStateChanged == gestureRecognizer.state) {
// Do repeated work here (repeats continuously) while finger is down
}
if(UIGestureRecognizerStateEnded == gestureRecognizer.state) {
// Do end work here when finger is lifted
}
}
}
I Hope This would help you to detecting the cursor movement over UITextField
Upvotes: 0