Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alter keyboard appearance in native, phonegap/Cordova built iOS App

I want to change the background color of all the keyboards appearing in my Phonegap/Cordova built native iOS App as shown below:

enter image description here

I have googled this thoroughly of course and found mainly 2 relevant answers. The answerer here says that Objective-C code can be added to the PhoneGap project's AppDelegate.m file as shown on this page. I've located the AppDelegate.m file but can't seem to figure out how to set the keyboard appearance to that of UIKeyboardAppearanceAlert on all textfields. Code example provided by the answerer:

 mytextfield.keyboardAppearance = UIKeyboardAppearanceAlert;

Writing an app based on cordova, I can't distinguish any textfield IDs to connect to the above example. Is there a file in Xcode / Cordova in which all the textfield IDs are listed, or even better:

Is there a way in which I can set the keyboard appearance to dark through UIKeyboardAppearanceAlert or similar approaches, that applies to all textfields and is compatible with Cordova?

Thanks

like image 600
Jonathan Avatar asked Aug 09 '12 18:08

Jonathan


3 Answers

After sharing this question widely on various social media, more extensive and thorough research, asking friends and aquaintances, etc I can only come to the conclusion that this cannot be done using phonegap and cordova. I would love for anyone to prove me long. For the time being however, this is what I shall conclude.

like image 155
Jonathan Avatar answered Oct 23 '22 12:10

Jonathan


As far as I know you can't do that with Cordova without major hacks, which probably won't be appreciated by Apple. But not sure.

like image 40
user1609071 Avatar answered Oct 23 '22 12:10

user1609071


There is no way to apply it to ALL text fields in your app without going through your code and manually setting the style of each uitextfields keyboard to the dark one.

EDIT 2: Unfortunately, it doesn't look like there's any possible way to do this without tapping into the Phonegap framework. And It doesn't look like this is possible without "hacking" into it as mentioned above.

EDIT: There doesn't seem to be any HTML element for the input tag (from Apple's Mobile Safari or Phonegap) that you can set to make the appearance into a alert. So (if possible) do a search for UITextField *.

Like in this image...

And right under the line that should look somewhat like this:

UITextField *field = [[UITextField alloc] init...];

Add this line

field.keyboardAppearance = UIKeyboardAppearanceAlert; // just like in your example...

If you do this for all the UITextField results then all your keyboards will look like the picture in your description.

like image 41
ManOx Avatar answered Oct 23 '22 13:10

ManOx