UIWebView 水平反弹不起作用 [英] UIWebView horizontal bounce not working

查看:24
本文介绍了UIWebView 水平反弹不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的 UIWebView 水平反弹,它已经垂直反弹,但只是没有进行水平反弹.

I am trying to get my UIWebView to bounce Horizontally, it already bounces vertically but its just not doing the Horizontal bounce.

我像这样添加了 UIWebView

I add the UIWebView like this

// pass data off to the correct view to be used
    lpViewController = [[LPViewController alloc] init];
    lpViewController.view.frame = CGRectMake(0.0, infoBarHeight, lpViewController.view.bounds.size.width, lpViewController.view.bounds.size.height);

    lpViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    lpViewController.view.backgroundColor = [UIColor whiteColor];


    [self.view insertSubview:lpViewController.view belowSubview:actionTabBar];

然后在 lpViewController viewDidLoad 方法中,我尝试像这样获得水平反弹.

Then inside lpViewController viewDidLoad method I have tried to get the horizontal bounce like this.

for (UIView *subview in [lockPositionsWebView subviews]) {
    if ([subview isMemberOfClass:[UIScrollView class]]) {
        [(UIScrollView *)subview setAlwaysBounceVertical:YES];
        [(UIScrollView *)subview setAlwaysBounceHorizontal:YES];
    }
}

lockPositionsWebView.scrollView.bounces = NO;

lockPositionsWebView.scrollView.alwaysBounceVertical = YES;
lockPositionsWebView.scrollView.alwaysBounceHorizontal = YES;

但这也不起作用,它获得了垂直反弹而不是水平反弹...

but thats not working either, it gets the Vertical bounce but not the Horizontal...

任何帮助将不胜感激.

推荐答案

要让您的 UIWebView 水平和垂直反弹,请将滚动视图的 bounces 属性设置为.

To get your UIWebView to bounce both horizontally and vertically, set the bounces property of the scrollview to YES.

将上面的代码更改为:

lockPositionsWebView.scrollView.bounces = YES;

lockPositionsWebView.scrollView.alwaysBounceVertical = YES;
lockPositionsWebView.scrollView.alwaysBounceHorizontal = YES;

bounces 属性必须为 YESalwaysBounceVerticalalwaysBounceHorizo​​ntal 才能工作.

The bounces property must be YES for alwaysBounceVertical and alwaysBounceHorizontal to work.

请参阅 Apple 的关于 alwaysBounceHorizo​​ntal 的文档:

See Apple's doco for alwaysBounceHorizontal:

一个布尔值,用于确定弹跳是否总是发生在水平滚动到达内容视图的末尾.
如果此属性设置为 YES 并且bounces 为 YES,则水平拖动为即使内容小于滚动的边界也允许看法.默认值为 NO.

A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
If this property is set to YES and bounces is YES, horizontal dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.

这篇关于UIWebView 水平反弹不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆