我试图让我的 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;
但这也不起作用,它得到垂直反弹而不是水平反弹......
任何帮助将不胜感激。
Best Answer-推荐答案 strong>
要让您的 UIWebView 水平和垂直反弹,请将 ScrollView 的 bounces 属性设置为 YES 。
将上面的代码更改为:
lockPositionsWebView.scrollView.bounces = YES;
lockPositionsWebView.scrollView.alwaysBounceVertical = YES;
lockPositionsWebView.scrollView.alwaysBounceHorizontal = YES;
bounces 属性必须为 YES ,alwaysBounceVertical 和 alwaysBounceHorizontal 才能工作。
请参阅 Apple 的 alwaysBounceHorizontal 文档:
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/
|