Cordova iOS cannot disable Keyboard Shrinks View - ios

With latest Cordova on iOS 8.1, it seems I cannot prevent the keyboard to shrink the view height.
I've tried the following settings:
in my config.xml:
<preference name="KeyboardShrinksView" value="false" />
in the index.html viewport tag:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
or
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
or
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
None of these disabling the shrink behavior.
How could I prevent the keyboard from shrinking the view on iOS?

I'm experiencing a very different problem. I can't get cordova to resize the webview like it used to anymore ^^.
with regards to
<preference name="KeyboardShrinksView" value="false" />
This is disregarded on ios7 and higher in the org.apache.cordova.labs.keyboard plugin.
The code states:
// No-op on iOS7. It already resizes webview by default, and this plugin
// is causing layout issues
// with fixed position elements. We possibly should attempt to implement
// shrinkview = false on iOS7.
if (!IsAtLeastiOSVersion(#"7.0")) { ... }
I suspect the culprit/savior is in the meta tag. That's where I'm going to look.
Currently mine looks like this:
'<meta name="viewport" content="width=' + viewPortWidth + ', user-scalable=no, initial-scale=1, maximum-scale=1' + extra + '"/>'
where viewPortWidth is dependent on the device, in case of an iphone it's 320, and extra is target-densityDpi=device-dpi in case it's android
Hope it can help you a bit

Related

autosize screen in phonegap

I use this meta parameters and javascript for try autosize
<meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width, height=device-height,
target-densitydpi=device-dpi" />
Whith this parameter i cannot resize screen , and in one Samsung S4 see screen very small.
I try resize screen with javascript and aperance is bether
<script type="text/javascript">
function resolution_handling()
{
//first way to implement
browser_width = $(window).width();
browser_height = $(window).height();
$("#page1").css("width":browser_width+"px");
$("#page1").css("height":browser_height+"px");
//second way to implement
browser_width = screen.width;
browser_height = screen.height;
$("#page1").css("width":browser_width+"px");
$("#page1").css("height":browser_height+"px");
}
</script>
But with this script footer is showed follow element not is showed in botton of page.
What it's the best method for resize screen is with this javascreipt?
How i can put footer in botton of page?
Add target-densitydpi=medium-dpi to your meta tag, that will fix your problem for high resolution screens like Samsung S4
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=medium-dpi" />
NO JAVASCRIPT NEEDED
Here's what I use and screen is auto-sized depending on the device's size and dpi an portrait/landscape :
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
I think your issue comes from the user-scalable=yes.

Phonegap IOS - scrollbar appear while I try to scroll home page even if html file was empty

I just create a IOS Phonegap app using Terminal, then change
UIWebViewBounce t= false in config.xml, and delete all contents inside
body, and delete all CSS data.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
<script type="text/javascript" src="cordova-2.4.0.js"></script>
</head>
<body>
</body>
</html>
This is my HTML page, my index.css is empty and my Phonegap version is 2.4. Then I run the app:
When I try to scroll the empty page, a scroll bar appears:
Why? Can anyone please help me?
**UPDATE Solved : just remove height=device-height from meta tag OR Remove status bar **
Yes, This is due to the device status bar, me also faced this issue, it will take almost 20px of window height. Better make sure that you have checked "Hide status bar" option in xcode Targets.
None of these solutions worked for me. I had to manually disable the iOS's WebView's ScrollView's ScrollIndicator, in the XCode project.
self.webView.scrollView.showsVerticalScrollIndicator = NO;

Resize site width to fit within width of iPad screen

I have a site that is 2048px wide. Is there a way to automatically have the iPad fit the entire site width on the screen when the site is loaded? I've tried experimenting with meta viewport in a few different ways:
<meta name="viewport" content="width=device-width maximum-scale=1.0">
<meta name="viewport" content="width=device-width initial-scale=1.0">
This hasn't worked though. The site is still too wide and spills off screen on the iPad.
You can pass a fixed size to the content width like so:
<meta name="viewport" content="width=2048" />
May need some tweaking to allow for padding either side, but should load the site at that size and allow users to zoom in.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
That's what I use for my website.
The correct way to fix this problem are by using percentages rather than fixed widths. But if you "cannot" change that, you can force your viewport to scale down by using 0.x in initial-scale like:
<meta name="viewport" content="width=device-width, initial-scale=0.625, user-scalable=yes" />
Try setting min-width: 2048px; to the html and body tags in css. That's fixed some weirdness on iPads for me before, but not sure if it will apply to this one.
I was working on a site with the same problem recently, it wouldn't stay zoomed out between page clicks for a fixed 960px width site. Try:
<meta name="viewport" content="width=device-width, initial-scale=-100%" />
So far so good, passed on my Ipad Air.
This works fine:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">

phonegap 2.2 orientation change does not resize app

I didn't have this problem on previous versions of Phonegap. But in 2.2, when I change the orientation, it doesn't update the uiwebview.
Does phonegap not support landscape view by default? How do you handle this?
This is not an issue with the WebView getting updated but with the meta tag in the index.html's document head.
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
After removing the unnecessary height=device-height everything works just fine
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />
To add to Stephan's answer, if you need to do anything special when the orientation changes, you can set a callback function to:
window.onorientationchange
I have also have same issue in ios phonegap ....
Just go and update x-code project file (IOS Application target ) change or update support interface orientation and check it all orientation .
it's work well ...
window.addEventListener(
"orientationchange",
function() {
// Announce the new orientation number
location.reload();
}, false );

phonegap iOS rotation

I'm working with the iOS simulator, it rotates fine, but unlike android the webview doesn't seem to re-size automatically. The orientationchanged event fires but I'm not sure how to handle refreshing the page. I can't do a whole page refresh, although it does solve the problem, since I'm using the multi-page JQmobile template. Any thoughts on other ways to re-size? I've tried $.mobile.trigger('pagecreate'); and pageshow.
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0 target-densityDpi=device-dpi" />
have you kept this
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
in <head> of the index.html in IOS it will automatically resize when device rotated.

Resources