Esto funcionó para mí.
UILabel Subclase y anular estos métodos:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (BOOL)canPerformAction:(SEL)action
withSender:(id)sender
{
return (action == @selector(copy:));
}
- (void)copy:(id)sender {
[[UIPasteboard generalPasteboard] setString:self.text];
}
Añadir gesto a su marcador para detectar grifo.
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LongPressDetected:)];
[_messageLabel addGestureRecognizer:longPress];
evento de gesto de la manija, presentan un UIMenuController con el marco deseado:
- (void)LongPressDetected:(UILongPressGestureRecognizer*)gesture {
[_messageLabel becomeFirstResponder];
[[UIMenuController sharedMenuController] setTargetRect:_messageLabel.bounds inView:_messageLabel];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:NO];
}
UILabel convertirse en un primer nivel de respuesta? ¿Qué quieres que responda? – kennytm
Hereda de UIResponder por lo que tiene la capacidad. – Ben
Estoy usando la biblioteca de alguien que hace cosas cuando un objeto con ciertas propiedades se convierte en el primer respondedor. También envía mensajes al primer respondedor. Sucede que quiero atar todo esto a mi etiqueta. –