0

我在我的 ios 应用程序中使用 photoswipe 3.0.5。在模拟器(ios 6.1)中一切正常,但是当我在我的真实设备(ios4.3)上运行应用程序并且我从纵向旋转到横向,反之亦然,uiwebview 正确旋转但图像没有。

这似乎是一个常见问题,事实上 photoswipe 的 github 页面(https://github.com/codecomputerlove/PhotoSwipe)说:

Work around for issue #141 now officially added - when rotating an app with PhotoSwipe displayed in a UIWebView, PhotoSwipe does not rotate. This seems to be an issue with UIWebView not PhotoSwipe. To enable this work around, set "enableUIWebViewRepositionTimeout = true" when creating your PhotoSwipe instance. You can also specify the frequency of this timeout by setting "uiWebViewResetPositionDelay" (default 500ms) - Please Note This is not needed for PhoneGap apps, nor web apps added to your homescreen.

但我不知道在哪里添加那行代码。谁能帮我一把?

这种“变通”真的有用吗?我问这个问题是因为模拟器上一切正常。

4

1 回答 1

0

我刚刚找到了答案。您需要做的就是将 'enableUIWebViewRepositionTimeout: true' 添加到 'options' 变量中:

    (function(window, PhotoSwipe){

        document.addEventListener('DOMContentLoaded', function(){

            var
                options = {
                    enableUIWebViewRepositionTimeout: true,
                    preventHide: true,
                    getImageSource: function(obj){
                        return obj.url;
                    },
                    getImageCaption: function(obj){
                        return obj.caption;
                    }
                },
                instance = PhotoSwipe.attach( 
                    [
                        ...

                    ], 
                    options 
                );

                instance.show(0);

        }, false);


    }(window, window.Code.PhotoSwipe));
于 2013-05-08T19:14:43.697 回答