开发者

UIWebView in UIPopoverController

开发者 https://www.devze.com 2023-03-06 05:54 出处:网络
I have a Universal application.In the iPhone version I have a view controller and nib which just loads a U开发者_如何转开发I webview with a local html file composed of jQueryMobile markup.It works jus

I have a Universal application. In the iPhone version I have a view controller and nib which just loads a U开发者_如何转开发I webview with a local html file composed of jQueryMobile markup. It works just as expected.

In the iPad version, I am loading that same view into a popover view controller and then display it. This works, but with a nagging anomaly. The UIWebview renders the content so that horizontal scrolling is needed to see all the content, even though it does not need to do so. I've sized the popover view size to be the size of an iPhone view(320x480). It does not render so that horizontal scrolling is needed in the iPhone.

Any ideas?


I found the problem. Turns out there's a bug in iOS for the iPad where it returns the full device width instead of the view width in a popover. jQuery has default behavior to get the viewport content using the device width.

I was able to override the default jQuery behavior by having another javascript file referenced between the jquery reference and the jquery mobile reference and that file contained the following:

$(document).bind("mobileinit", function(){
    $.mobile.metaViewportContent = "width=320, minimum-scale=1, maximum-scale=1";
});

Works like a charm!

0

精彩评论

暂无评论...
验证码 换一张
取 消