4

I am thinking that the UIInputViewController on a keyboard extension has some limitations.

First problem:

I NEVER add a subview to inputView or view, yet when I create an instance of a view from a nib it AUTOMATICALLY sets that view as the default view. Not normal.

Second problem:

I have two separated views in a single XIB file.

enter image description here

One is for the letter keyboard (and its subviews) and the other is for the number keyboard (and its subviews). The only way I can get this keyboard to appear is to use:

self.view!.insertSubview(self.mainViewNumberKeyboard, aboveSubview: self.mainViewLetterKeyboard)

This makes it visible, but the view does not accept user interaction. The keys from the underlying letter keyboard intercepts all the views.

If I do self.mainviewLetterKeyboard.hidden = true BOTH views disappear (letter and number keyboards). (This is where I think Apple may have a bug or issue - this should not happen)

I have similar problems if I have two separate XIB files each with their own keyboard. It appears that UIInputViewController does not like you to remove a view entirely from its superview.

Third Problem:

self.inputView doesn't seem to work. Adding subviews to it causes the keyboard to crash whereas self.view!.insertSubview seems to be the only way to get my number keyboard to appear

DESIRED RESULT

  1. User presses 123 button on keyboard
  2. Letter keyboard is removed from superview
  3. Number keyboard is added to UIInputViewController.view
  4. User presses ABC on number keyboard
  5. Number keyboard is removed from superview
  6. Letter keyboard is added to UIInputViewController.view

Anyone successfully add and remove MULTIPLE views on a keyboard extension?

4

2 回答 2

0

我的问题与 Xcode 6 Beta 2 问题有关。您现在可以在 Xcode Beta 3 中正确加载 XIB 文件。

本教程将逐步完成:http: //verisage.us/blog/2014/07/17/ios-8-custom-keyboard-swift-tutorial/

于 2014-07-19T04:01:23.090 回答
0

UIInputViewcontroller有一个UIInputView名为inputViewwhich extends的引用UIView

inputView是您添加子视图的视图。

这是否回答你的问题?

于 2014-07-14T15:26:07.887 回答