4

I'm trying to write a custom keyboard for iOS8 and so far, minus the odd hiccup, I've not had too many issues. However, when I create a view and add it as a subview of a UIButton I've added to the keyboard view the newly added view is clipped at the top of the keyboard view. From what I can tell, the hierarchy is as follows:

UIView (popup) -> UIButton (actual "key") -> UIInputView

With this hierarchy, the top-level UIView is being clipped inside the UIInputView. Each UIView has had clipsToBounds set to false, and I also set the UIView (self.view) to false within the UIInputViewController, but that doesn't seem to have helped.

It could be that this is a restriction of the extension system currently, but hopefully it's something silly I'm doing!

Andrew
  • 15,357
  • 6
  • 66
  • 101
Joseph Duffy
  • 4,566
  • 9
  • 38
  • 68
  • 1
    The system won't allow it. "In addition, it is not possible to display key artwork above the top row, as the system keyboard does on iPhone when you tap a key in the top row." – Spentak Jun 12 '14 at 00:36
  • Joseph - can you send me a link to your code? I'm trying to add subviews but the keyboard always comes up blank and does not show my UIButtons. I'd love to see an implementation that is working – Spentak Jun 12 '14 at 00:37
  • @Spentak I just found that quote in the documentation, thanks. It seem far too restrictive to be able to make and iOS-like keyboard, which is quite a shame. When you create a new keyboard extension target it provides some example code with a button to take you to the next keyboard, use that a starting point? – Joseph Duffy Jun 12 '14 at 09:33
  • Possible duplicate of my issue : http://stackoverflow.com/questions/26293583/ios-8-keyboard-extension-issue-with-adding-pop-up-of-keys/26409730#26409730 If you examine the view hierarchy you can see that the UIWindow holding the keyboard extension doesn't extend above the keyboard, so even if you turn off clipsToBounds in the entire view hierarchy up to the window, you still can't display outside the window. – Muzammil Oct 16 '14 at 18:22

1 Answers1

5

This is actually not possible. According to the docs it states "In addition, it is not possible to display key artwork above the top row, as the system keyboard does on iPhone when you tap a key in the top row.", which is a shame.

Thanks to @Spentak for pointing that out

Joseph Duffy
  • 4,566
  • 9
  • 38
  • 68
  • Thanks! Can't believe Apple adds this stupid restriction. We cannot show the popup for a key on a custom keyboard because it is clipped! It is a shame! Do you have any work around? I really want to show something out of the keyboard area. – Vince Yuan Aug 21 '14 at 15:08
  • that guideline has changed with beta5 – lucaconlaq Sep 07 '14 at 09:49
  • @Luka Can you link to the documentation stating that? I've just made a simple project and still can't draw outside the keyboard's view, and the originally linked documentation still states it's not possible – Joseph Duffy Sep 07 '14 at 11:48
  • take a look at this http://stackoverflow.com/questions/25010193/how-to-toggle-a-word-selection-view-change-height-in-ios-custom-keyboard/25675775#25675775 They changed the documentation with the release of beta5, of that I'm sure – lucaconlaq Sep 08 '14 at 20:51
  • @Luka That shows changing the size of the keyboard, not drawing outside of the keyboard's view. Whilst you could increase the size of the keyboard and have the top section transparent, it's likely that sending touch events to the view behind would not be possible. This doesn't currently solve the issue of drawing something outside of the keyboard's view. – Joseph Duffy Sep 08 '14 at 22:21