4

I would like to create a subclass of UITextView with a custom button to invoke Siri on (for its speech-to-text text entry). Is this possible? I don't mind if the keyboard is shown, I just want to provide my own button to turn on Siri.

lmirosevic
  • 15,787
  • 13
  • 70
  • 116

1 Answers1

2

You can't do that unfortunately (as of iOS 6.0). The only way to use Siri is to use UITextFields and let the user enter text by dictating to Siri.

DrummerB
  • 39,814
  • 12
  • 105
  • 142
  • @RichardJ.RossIII Without using private APIs? Good luck. – DrummerB Sep 26 '12 at 18:15
  • The OP never specified. But i'll see what I can do using the runtime & public APIs. – Richard J. Ross III Sep 26 '12 at 18:19
  • @RichardJ.RossIII I advise you to use some sort of obfuscation, e. g. base85- or RSA-encode the private classes and selector names you use... Then you can hit objc_getClass() etc. (Btw seen my iPod import library?) –  Sep 26 '12 at 18:36
  • @H2CO3 first I'm gonna make it work simple. I already have access to the keyboard layout, it's just a matter of toying with the right subviews to make siri pop up. Then I'll work on obfuscation. – Richard J. Ross III Sep 26 '12 at 18:42
  • Just an update: I'm able to now get the dictation button on-screen, and trying to figure out how to fire it (as it isn't a UIButton). – Richard J. Ross III Sep 26 '12 at 18:49
  • @RichardJ.RossIII maybe send a `touchesEnded:withEvent:` to the main window at that point, it will pass it down the responder chain. (i. e. simulate a touch.) –  Sep 26 '12 at 18:55
  • @RichardJ.RossIII or just class-dump. –  Sep 26 '12 at 18:55
  • @H2CO3 that's quite possible, but the one thing I don't want is for this to be device-specific. – Richard J. Ross III Sep 26 '12 at 18:57
  • @RichardJ.RossIII that's your response to the simulated touch or to class-dump? –  Sep 26 '12 at 19:03
  • 1
    @H2CO3 no, what I'm saying is that I am dumping the classes - I just can't quite find the selector to fire the button - yet. – Richard J. Ross III Sep 26 '12 at 19:04
  • @RichardJ.RossIII Any progress to report? – Mick MacCallum Jan 27 '13 at 18:49
  • @0x7fffffff unfortunately, no. It appears that the keyboard on ios is not based off of the traditional UIView hierarchy, and simulating a touch did not appear to affect the keyboard. While I was able to access a class which indicated it was the Siri button, it did not have any methods to invoke to activate Siri. – Richard J. Ross III Jan 27 '13 at 19:24
  • @RichardJ.RossIII Damn, it's really a shame there isn't any API for this. Thanks for putting the effort into trying though! – Mick MacCallum Jan 27 '13 at 19:40
  • @0x7fffffff, you can accomplish the task [by simulating a home button long press, as shown here](http://stackoverflow.com/a/18671422/119114). – Nate Sep 11 '13 at 00:01