UIInputViewController 键盘未在 iOS 8 中显示
Posted
技术标签:
【中文标题】UIInputViewController 键盘未在 iOS 8 中显示【英文标题】:UIInputViewController keyboard not displaying in iOS 8 【发布时间】:2014-07-01 06:18:13 【问题描述】:我创建了自定义键盘。但有时我的键盘没有显示在我的 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 切换键盘(在模拟器上) 【参考方案1】:您是否遵循了这些步骤?因为它对我来说非常完美。更多你可以找到here
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.
【讨论】:
【参考方案2】:这里也一样!判断是iOS8 beta版的bug,退出显示键盘的app,重新启动app,键盘就可以正常显示了。
【讨论】:
以上是关于UIInputViewController 键盘未在 iOS 8 中显示的主要内容,如果未能解决你的问题,请参考以下文章