0
Когда я пишу что-то в UITextfield и дважды нажимаю на него, он показывает опцию «Выбрать», «Выбрать ВСЕ», «Вставить» на устройстве ios. Я хочу отображать такое же сообщение через программирование.Как имитировать двойной щелчок на UITextField?
Может ли кто-нибудь предложить способ сделать это?
Двойной контакт не срабатывает с кодом ниже.
+(void)performanualTouch:(UITouch*)touch {
UIEvent *eventDown = [[UIEvent alloc] initWithTouch:touch];
for (UIGestureRecognizer* gr in touch.view.gestureRecognizers) {
if ([gr isKindOfClass:[UITapGestureRecognizer class]]) {
[gr touchesBegan:[eventDown allTouches] withEvent:eventDown];
[touch setThePhase:UITouchPhaseEnded];
UIEvent *eventUp = [[UIEvent alloc] initWithTouch:touch];
[gr touchesEnded:[eventUp allTouches] withEvent:eventUp];
[eventUp release];
if (gr.cancelsTouchesInView) {
return;
}
}
}
[touch.view touchesBegan:[eventDown allTouches] withEvent:eventDown];
[[UIApplication sharedApplication] sendEvent:eventDown];
[touch setThePhase:UITouchPhaseEnded];
UIEvent *eventUp = [[UIEvent alloc] initWithTouch:touch];
[touch.view touchesEnded:[eventUp allTouches] withEvent:eventUp];
[[UIApplication sharedApplication] sendEvent:eventUp];
[eventDown release];
[eventUp release];
}
Благодаря
Это должно помочь вам достаточно [ссылка] (HTTP: // StackOverflow .com/вопросы/8277535/КСН-хау к Simulate-два-краны-на-UITextView-программно). –