iOS 8中UIInputViewController键盘未显示

3
我可以帮助您进行翻译。以下是您需要翻译的内容:

我创建了自定义键盘。但有时我的iOS8 iPhone5S上没有显示我的键盘。

请检查下面的代码。我做错了什么吗?

我的代码:

   // Perform custom UI setup here
self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];

[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
[self.nextKeyboardButton sizeToFit];
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;

[self.nextKeyboardButton addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:self.nextKeyboardButton];

NSLayoutConstraint *nextKeyboardButtonLeftSideConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
NSLayoutConstraint *nextKeyboardButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];



UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(0.0, 0.0, 160.0, 160.0);
[self.view  addSubview:button];


[self.view addConstraints:@[nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]];

尝试按下 Cmd+K 来切换键盘(在模拟器上)。 - Tony
2个回答

2

你是否按照这些步骤进行操作?因为对我来说,它完美地运行了。更多信息可以在此处找到。

Use the toolbar to ensure that the active scheme specifies the containing app and an iOS Simulator device.

Choose Product > Run, or click the Play button at the upper left of the Xcode project window.
After the containing app and keyboard build and get installed in the simulator, you see the empty containing app running.

In iOS Simulator, choose Hardware > Home to view Springboard.
Go to Settings > General > Keyboard > Keyboards.
Tap Add New Keyboard.

In the Purchased Keyboards group, tap the name of your new keyboard. A modal view appears with a switch to enable your keyboard.

Tap the switch to enable your keyboard. A warning alert appears.
In the warning alert, tap Add Keyboard to finish enabling your new keyboard. Then tap Done.
Choose Hardware > Home to view Springboard.

In Springboard, pull down to reveal the Spotlight search field.

In the system keyboard, now onscreen, tap and hold the globe key to show the list of enabled keyboards. Then tap on the custom keyboard you just installed.

0

我也遇到了同样的问题!我得出结论,这是iOS8测试版中的一个bug。你可以通过退出键盘显示的应用程序,然后重新启动应用程序,键盘就会正常显示。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接