我在ios应用程序中使用photoswipe 3.0.5。一切都在模拟器(ios 6.1)中正常工作,但是当我在我的真实设备(ios4.3)上运行应用程序并且我从纵向旋转到横向时,反之亦然,uiwebview正确旋转但图像没有。
这似乎是一个常见的问题,事实上,照片的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 :(得分:0)
我刚刚找到答案。您需要做的就是将'enableUIWebViewRepositionTimeout:true'添加到'options'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));