- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan");
//test
UITouch *touch = [event allTouches] anyObject];
if ([touch tapCount] == 2) {
NSLog (@"tapcount 2");
[self.textview becomeFirstResponder];
}
else if ([touch tapCount] == 1) {
NSLog (@"tapcount 1");
[self.textview becomeFirstResponder];
[self.view performSelector:@selector(select:)];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"****touchesEnded");
[self.nextResponder touchesEnded: touches withEvent:event];
NSLog(@"****touchesEnded");
[super touchesEnded:touches withEvent:event];
NSLog(@"****touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesCancelled:touches withEvent:event];
NSLog(@"touchesCancelled");
}
MIA DOMANDA:ios Come rendere UITextView rilevare un tocco?
voglio simulare due rubinetti quando si tocca una volta su un UITextView, che è TextView in questo codice. Ma non ottengo NSLog da uno e due tocchi quando tocco una o due volte su textview, solo al di fuori di esso. Cosa dovrei fare per farlo funzionare?
Prima di tutto questo codice dovrebbe essere in una sottoclasse UITextView personalizzata per funzionare e probabilmente interferirebbe con il normale funzionamento. In secondo luogo, cosa intendi con "Voglio simulare due tocchi quando tocchi una volta su un UITextView", intendo per quale scopo? – NJones
@NJones Desidero dare agli utenti un'opzione per scegliere tra uno o due tocchi per una determinata funzione. Voglio simulare due tocchi per ottenere il testo selezionato e renderlo un solo tocco per gli utenti se scelgono questa opzione. È possibile forzare due tocchi quando si tocca una volta su UITextView? la soluzione di bensnider funziona perfettamente. Ma come simulare due tap? – wagashi