2015-03-11 17 views

risposta

11

Sì, è possibile. Ecco la documentazione: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/presentTextInputControllerWithSuggestions:allowedInputMode:completion:

Il codice è simile a questo. Fornisci un array di suggerimenti con parole (o anche emoji) e imposti la modalità di input consentita che può accettare solo emoji animati, emoji o testo del piano.

[self presentTextInputControllerWithSuggestions:@[@"hello", @"world"] allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) { 
    NSLog(@"results: %@", results); 
}]; 

Il risultato è questo:

enter image description here

+0

Sei a conoscenza di ogni caso per simulare la dettatura? So che il simulatore non lo supporta, e Apple Watch non è ancora disponibile, comunque per testarlo? – prawn

+1

Non è possibile testarlo in Simulator e dubito che sarà disponibile a breve. Probabilmente richiederà un dispositivo reale per testarlo. – BalestraPatrick

+0

Grazie U !! per la tua risposta @BalestraPatrick –

6

Si può chiedere per l'input dell'utente e dargli suggestione (vedi esempio Swift sotto).

self.presentTextInputControllerWithSuggestions(["suggestion 1", "suggestion 2"] allowedInputMode: .Plain, completion: { (answers) -> Void in 
    if reply && reply.count > 0 { 
     if let answer = answers[0] as? String { 
      println("\answer") 
     } 
    } 
}) 

Se suggerimento è nullo si va direttamente alla dettatura. Non sta funzionando sul simulatore ma è sull'orologio reale.

0
self.presentTextInputControllerWithSuggestions(["Y","N"], allowedInputMode: WKTextInputMode.Plain, 
    completion:{(results) -> Void in 
     let aResult = results?[0] as? String 
     print(aResult) 
})