[英]Which delegate method will get fired in UITextfield or UITextview?
I want to know which delegate method will get fired when we long press the UITextfield or UITextview to move the cursor? 我想知道当我们长按UITextfield或UITextview移动光标时会触发哪个委托方法? Please help me out. 请帮帮我。
You should use the Gesture Recognizer for this purpose 您应该使用手势识别器来实现此目的
1)Firstly Add Recognizer to your TextFiled 1)首先将识别器添加到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 2)您可以在检测到光标移动如下之后编写逻辑
**-(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 我希望这可以帮助您检测UITextField上的光标移动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.