gpt4 book ai didi

ios - UIWebView 水平弹跳不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:46:27 26 4
gpt4 key购买 nike

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

我这样添加 UIWebView

// 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 方法中,我尝试像这样获得水平反弹。

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;

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

如有任何帮助,我们将不胜感激。

最佳答案

要让您的 UIWebView 水平和垂直反弹,请将 ScrollView 的 bounces 属性设置为 YES

将上面的代码更改为:

lockPositionsWebView.scrollView.bounces = YES;

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

bounces 属性必须为 YES 才能使 alwaysBounceVerticalalwaysBounceHorizo​​ntal 正常工作。

请参阅 Apple 的 alwaysBounceHorizo​​ntal 的 doco:

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.

关于ios - UIWebView 水平弹跳不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17354895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com