如何关闭UIWebView水平弹跳
简单的问题,我有一个 webview,它应该只包含一个图像,以便用户能够放大和缩小。为了保持外观干净,我想完全禁用此视图上的弹跳,但仍然允许滚动。该解决方案确实适用于垂直反弹,但是一旦我将图像缩放到大于屏幕的尺寸,水平反弹仍然是可能的:
for (id subview in webView.subviews
{
if ( [[subview class] isSubclassOfClass:[UIScrollView class]] )
{
((UIScrollView*) subview).bounces = NO;
((UIScrollView*) subview).alwaysBounceVertical = NO;
((UIScrollView*) subview).alwaysBounceHorizontal = NO;
((UIScrollView*) subview).bouncesZoom = NO;
}
}
Simple problem, I have a webview that is supposed to hold just an image for the user to be able to zoom in and out. To keep my look clean, I want to completely disable bouncing on this view, but still allow scrolling. This solution does work for the vertical bounce, but as soon as I zoom the image to a size larger than the screen, horizontal bounce is still possible:
for (id subview in webView.subviews
{
if ( [[subview class] isSubclassOfClass:[UIScrollView class]] )
{
((UIScrollView*) subview).bounces = NO;
((UIScrollView*) subview).alwaysBounceVertical = NO;
((UIScrollView*) subview).alwaysBounceHorizontal = NO;
((UIScrollView*) subview).bouncesZoom = NO;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的代码让我们停止弹跳:
我不确定这是否会禁用图像的缩放。但它应该会停止弹跳。
The following code did the trick for us to stop bouncing:
I am not sure if this will disable the zooming of image. But it should stop the bouncing.
在 iOS 5 上,您可以通过以下方式解决问题:
注意:这仅适用于 iOS5 及更高版本
On iOS 5 you can solve your problem this way:
NOTE: this will work only on iOS5 and higher