iPhone カスタムキーボードを作る

iPhone開発に置いて、キーボード入力をデフォルトのキーボードではなく、個別に用意したものと切り替え可能にする

1.UITextView, UITextFieldのinputViewに置き換えたいviewを設定

UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, bounds.size.width - 20, 30)];
    textField.borderStyle = UITextBorderStyleRoundedRect;
    CustomKeyboard* keyboard = [[CustomKeyboard alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, 200)];
    textField.inputView = keyboard;

2.キーボードが表示されている場合に切り替える場合はreloadInputViewsメッセージを送る

textView.inputView = nil; // デフォルトに戻す場合
[textView reloadInputViews]

以下サンプルコード
https://github.com/hrk-ys/ios-custom-inputview

0 件のコメント:

コメントを投稿

ReactNativeでAndroid対応する話

前提 ReactNativeでiOS版のアプリをリリースしていて、Android版をリリースする話 トラブルシューティング Build.VERSION_CODES.Q が存在しないエラー compileSdkVersionを29以上にすると解決 メモリー足りないエラー Execu...