あるサイトのカスタムキーボードの例というのを見ながらやってめしたが、以下のところのエラーがどうしても消えなくて困っています。
何が間違っているのでしょうか?
38行目と最後の78行目です。
#import "Keyboard.h" @interface KeyboardViewController () @property (strong,nonatomic) Keyboard *keyboard; @end @implementation KeyboardViewController - (void)updateViewConstraints { [super updateViewConstraints]; // Add custom view sizing constraints here } - (void)viewDidLoad { [super viewDidLoad]; // Perform custom UI setup here self.keyboard = [[[NSBundle mainBundle] loadNibNamed:@"Keyboard" owner:nil options:nil]objectAtIndex:0]; [self addGesturesToKeyboard]; self.inputView = self.keyboard;}←Incompatible pointer types assigning to 'UIInputView * _Nullable' from 'Keyboard *' - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; } - (void)textWillChange:(id<UITextInput>)textInput { // The app is about to change the document's contents. Perform any preparation here. } - (void)textDidChange:(id<UITextInput>)textInput { // The app has just changed the document's contents, the document context has been updated. UIColor *textColor = nil; if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) { textColor = [UIColor whiteColor]; } else { textColor = [UIColor blackColor]; } } #pragma mark Keyboards - (void)addGesturesToKeyboard{ [self.keyboard.deleteKey addTarget:self action:@selector(pressDeleteKey) forControlEvents:UIControlEventTouchUpInside]; [self.keyboard.spaceKey addTarget:self action:@selector(pressSpaceKey) forControlEvents:UIControlEventTouchUpInside]; [self.keyboard.returnKey addTarget:self action:@selector(pressReturnKey) forControlEvents:UIControlEventTouchUpInside]; //Change to keyboard [self.keyboard.globeKey addTarget:self action:@selector(pressSpaceKey) forControlEvents:UIControlEventTouchUpInside];} - (void)pressDeleteKey{ [self.textDocumentProxy deleteBackward];} - (void)pressSpaceKey{ [self.textDocumentProxy insertText:@""];} - (void)pressReturnKey{ [self.textDocumentProxy insertText:@"\n"];} - (void)pressKey:(UIButton *)key{ [self.textDocumentProxy insertText:[keycurrenTitle]];}←Use of undeclared identifier 'keycurrenTitle' @end
チェック項目がおかしかったせいで、エラーは回避できたのですが、今度はシミュレーターでキーボードを表示しなくなってしまいました。appなどのチェックを付けたり外したりしてたら、元がどれだか分からなくなりました…。
カスタムキーボードですが、Objective-Cである必要はありますでしょうか。
Swiftであれば参考になりそうな記事はいくつかありますし、とりあえずキーボードとして登録するための作業はかなり単純にできそうです。
たとえば、下記の記事などです。
https://qiita.com/Kyome/items/4257de4e33d3647085e6
以前、上記の方と連絡が取れて、やり方を聞きましたが、バージョンが古いのと、しばらくやってないとのことで、他を参考にして下さいと言われました。
で、下記のところでマネをしてみたのですhttps://riptutorial.com/ja/ios/example/24416/カスタムキーボードの例
スペルミスや、:と;を間違えてたりと、細々とした間違いの連続でした。
回答1件
あなたの回答
tips
プレビュー