Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
¿Cómo escribo esto en swift? Relacionado con UIKeyCommand

¿Cómo convierto esto en rápido? Este código toma el comando clave:

 export function isBackspace(keyCode: number): boolean { return keyCode === 8; } export function isDeleteForward( keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean, ): boolean { if (IS_APPLE) { if (shiftKey || altKey || metaKey) { return false; } return isDelete(keyCode) || (keyCode === 68 && ctrlKey); } if (ctrlKey || altKey || metaKey) { return false; } return isDelete(keyCode); }

He convertido así en swift:

 public func isBackspace(command: UIKeyCommand) -> Bool { return command.input == "\u{8}" } public func isDeleteBackward(command: UIKeyCommand, altKey: Bool, ctrlKey: Bool, commandKey: Bool ) -> Bool { if altKey || commandKey { return false } return isBackspace(command: command) || (command.input == "H" && ctrlKey) }

Pero cuando presiono el botón "eliminar" en el teclado, ¿no hace nada? ¿Me estoy perdiendo algo aquí? ¿Es correcta la conversión?

Este es mi código UIKeyCommand:

 override public var keyCommands: [UIKeyCommand]? { let commands = [ UIKeyCommand(input: "\u{8}", modifierFlags: .alternate, action: #selector(selectKeyTapped(command:))), UIKeyCommand(input: "\u{8}", modifierFlags: .command, action: #selector(selectKeyTapped(command:))), UIKeyCommand(input: "\u{8}", modifierFlags: .control, action: #selector(selectKeyTapped(command:))), UIKeyCommand(input: "\u{8}", modifierFlags: [], action: #selector(selectKeyTapped(command:))) ] if #available(iOS 15, *) { commands.forEach { $0.wantsPriorityOverSystemBehavior = true } } return commands } @objc func selectKeyTapped(command: UIKeyCommand) { guard let textView = textView else { return } if isDeleteBackward(command: command, altKey: true, ctrlKey: true, commandKey: true) { if isBackspace(command: command) { deleteCharacter(isBackwards: true) } else { deleteCharacter(isBackwards: true) } } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!