-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOS keyboard popup issue with header #123
Comments
I'm guessing you are experiencing this on iOS? The problem is the browser tries to center the focused element by scrolling the page. But scrolling the page isn't effective if you are using iScroll on the page. Unfortunately, there is not a good solution that I know of. I have solved this, but only for native apps that use a uiwebview. I've written an extension for Rhodes. One could certainly be written for PhoneGap using the same techniques. The extension is needed in order to know when the keyboard appears and disappears (focus/blur unfortunately is not enough to do the job) as well as the size of the keyboard. I believe, though, that iOS 7 may provide a path for better dealing with the virtual keyboard, because I think that for iOS7 now the browser actually resizes the viewport when the virtual keyboard appears. Closing this because it is a duplicate, and there is currently no solution. |
Thanks for this explanation |
Hey @HadiMakawi, Have you had any luck with this? I am able to get semi-decent results when I set the following configs. window.Keyboard.shrinkView(true); disableScrollingInShrinkView is fine with IScroll since iscroll handles all the scrolling for us and allows jquery mobile footers to stay fixed at the bottom. I'm wresting with the phonegap 3.2 keyboard plugin now. I can't get the webview resize to look alright. The webview always gets pushed up and then down during the resize. Any ideas? |
twilly86: can you clarify where the 3 functions you referenced above come from? Is this new ios7 functionality? Android functionality? (new/recent?) PhoneGap functionality (new/recent?) Some PhoneGap plugin(s). I'm not coming up with any useful Google search results. I haven't done any PhoneGap work since 2.2, so I'm pretty clueless on anything more recent. I have a client whose done his own update to PhoneGap 3.2, though, and so 'll have something I can experiment with. (The app doesn't have any inputs, but I can add some for an experiment.) Since I do have this working quite well in Rhodes with a custom plugin, I'll perhaps have an idea of what needs to be addressed to work with these functions. I'm re-opening this for now, because it sounds like there is at least a glimmer of hope to do this without a custom plugin. |
Hey guys I have managed to solve the issue I will provide you with the solution after the weekend (: A brief of what I did .. I get rid of Iscroll plugin I did some code changes on Cordova ViewControler class. Also I have added some Objective C code to stop pushing the uiwebview when keyboard opens and to call a Java script function when keyboard is open. This java script function re adjust the height of the HTML page after keyboard is up. |
Hadi - Yes, this is exactly the approach that I took to solve the problem for Rhodes - a combination of Objective-C code to stop pushing the UIWebView when the keyboard opens, and send a JS event when the keyboard opens (sending the size of the keyboard). Then a JS functon adjusts the height of the page. When the keyboard is closed, the above is reversed. ios7 throws a monkey-wrench, because now it shows the page under the keyboard. One should then be able to use iScroll and no scrolling of the UIWebView will occur, as long as the page height does not exceed the viewport height - and this is in fact normally the case if you are using iScroll. But this is optional, so if you tell it not to show the view under the keyboard, then it should work like ios6. In fact, if you build for iOS6, it just works the way it did previously. I think it's a matter of taste. I do prefer the old way, as I don't like the content showing under the keyboard. I think current apps are 50/50 on this choice. The last piece (that allows you to use iScroll, is to use a focus event to run some JS that will scroll the input into view when each field is focused. I've impleted a simple scheme where it just centers the input. A better way would be to do it intelligently, only scrolling if the input is not in view, and then only scrolling enough to bring the input into view. Then it would work similar to the native behavior. Of course, you could implement any kind of behaviour you would like on focus. If you want to implement this, I can probably help you out with some odd logic around the focus events. The more intelligent scrolling is something I am tasked to do, but not a very high priority. I do hope that I'll be permitted to release this code (a plugin for Rhodes, and the JS code for iscrollview) as open source at some point. Good to see there is a solution on the horizon for PhoneGap. |
I will explain how I have solved this issue. Objective-C: 1- In (void)viewDidLoad function 2- Comment the whole - (void)keyboardWillShow:(NSNotification*)notif function: //- (void)keyboardWillShow:(NSNotification*)notif //}
} 4- In MainViewController.m 4.1 in function - (id)init add the following at the end: 4.2 add the following function in MainViewController.m
self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); }
} 5 - My config.xml have the following 6 - In css I have the following for header, page and content:
.ui-page {
.ui-content {
7- JS functions: $(document).on('touchstart', 'input, textarea, select', function(e) {
}); $(document).on('touchend', 'input, textarea, select', function(e) {
}); $(document).on('focus', 'input, textarea, select', function(e) {
}); function needsFocus (type) { switch (type) {
default: function keyboardShow(keyboardheight){
}
} function active_scroll(el,height){
} function scroll_to(keyboardheight){
} 8 - in jquery.mobile-1.3.2.js Finally this is it, and sorry for this a lot of code and my bad English ): I hop you guys can get any benefit from it . Note: that app am doing is Portrait no Landscape I have not test it in Landscape. |
That is by far, the worst workaround of any issue or bug that I have ever encountered... |
This plugin addresses the native part of this issue, and could probably replace the native code above: https://github.com/driftyco/ionic-plugins-keyboard As well, I now have permission to release my own native code (for RhoMobile Rhodes platform) as open-source, and will coordinate with the Ionic project above. |
I am creating a web app using JQM + Iscroll everything is working perfectly but I have an issue which is if the page have input text the the user clicks on it the keyboard will popup and the header goes up its not fixed anymore it seemed like ios keyboard popup pushed the while uiwebview to center the page to the clicked input text.
Sorry for my bad English and I wish if someone can advise me with any soluations
The text was updated successfully, but these errors were encountered: