Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

455
Vistas
¿Cómo deshabilitar Copiar, seleccionar todo en UITextView usando Swift 4.2?

Cómo deshabilitar Copiar, seleccionar todo en UITextView , pero necesito que se pueda hacer clic en el enlace en UITextview .

Aquí se deshabilitan todas las acciones, pero se permite la selección. Solo necesito un enlace en el que se pueda hacer clic.

 override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { return false }
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

solo hijack ,

 func swizzle() { guard let cls = NSClassFromString("UITextSelectionView") else { return } let originalSelector = NSSelectorFromString("updateSelectionRects") let swizzledSelector = #selector(UIView.updateSelectionRectsHijack) let originMethod = class_getInstanceMethod(cls, originalSelector) let swizzleMethod = class_getInstanceMethod(UIView.self, swizzledSelector) if let swizzledMethod = swizzleMethod, let originalMethod = originMethod{ method_exchangeImplementations(originalMethod, swizzledMethod) } } extension UIView{ @objc func updateSelectionRectsHijack(){ } }

swizzle() debe llamarse una sola vez.


¿Cómo sé UITextSelectionView ?

Compruebe View Hierarchy ,

888


¿Cómo sé el método updateSelectionRects ?

a través del tiempo de runtime ,

import ObjectiveC ,

entonces,

 var count: UInt32 = 0 guard let methodArr = class_copyMethodList(NSClassFromString("UITextSelectionView"), &count) else { return } let cnt = Int(count) for i in 0..<cnt{ let method = methodArr[i] let name = method_getName(method) if let type = method_getTypeEncoding(method){ print(name, String(utf8String: type) ?? " _ | _ ") } }
over 4 years ago · Santiago Trujillo Denunciar

0

También puedes secuestrar, así

 let hijackInvocation: @convention(block) (Unmanaged<NSObject>, AnyObject) -> Void = { objectRef, invocation in } func swizzle() { guard let cls = NSClassFromString("UITextLoupeInteraction") else { return } let originalSelector = NSSelectorFromString("loupeGesture:") let originMethod = class_getInstanceMethod(cls, originalSelector) if let originM = originMethod{ let encode = method_getTypeEncoding(originM) class_replaceMethod(cls, originalSelector, imp_implementationWithBlock(hijackInvocation as Any), encode) } }

swizzle() debe llamarse solo una vez.


¿Qué es UITextLoupeInteraction ?

999

de la respuesta de @ dengST30.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda