2013-05-08 74 views
0

我在我的ios應用程序中使用photoswipe 3.0.5。一切工作正常在模擬器(ios 6.1),但是當我在我的真實設備(ios4.3)上運行應用程序,我從縱向旋轉到風景,反之亦然uiwebview正確旋轉,但圖像沒有。ios4中的Photoswipe旋轉問題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.

但我不知道在哪裏添加一行代碼。任何人都可以給我手?

這個「解決方法」真的有訣竅嗎?我在問這個問題,因爲在模擬器上一切正常。

回答

0

我剛找到答案。您只需在'options'中添加'enableUIWebViewRepositionTimeout:true'var:

(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));