菜鸟教程小白 发表于 2022-12-13 02:56:36

ios - UIWebView 水平反弹不起作用


                                            <p><p>我试图让我的 UIWebView 水平反弹,它已经垂直反弹,但它只是不做水平反弹。</p>

<p>我这样添加 UIWebView</p>

<pre><code>// pass data off to the correct view to be used
    lpViewController = [ 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 = ;


    ;
</code></pre>

<p>然后在 lpViewController viewDidLoad 方法中,我尝试像这样获得水平反弹。</p>

<pre><code>for (UIView *subview in ) {
    if (]) {
      [(UIScrollView *)subview setAlwaysBounceVertical:YES];
      [(UIScrollView *)subview setAlwaysBounceHorizontal:YES];
    }
}

lockPositionsWebView.scrollView.bounces = NO;

lockPositionsWebView.scrollView.alwaysBounceVertical = YES;
lockPositionsWebView.scrollView.alwaysBounceHorizontal = YES;
</code></pre>

<p>但这也不起作用,它得到垂直反弹而不是水平反弹...... </p>

<p>任何帮助将不胜感激。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>要让您的 <code>UIWebView</code> 水平和垂直反弹,请将 ScrollView 的 <code>bounces</code> 属性设置为 <code>YES</code>。</p>

<p>将上面的代码更改为:</p>

<pre><code>lockPositionsWebView.scrollView.bounces = YES;

lockPositionsWebView.scrollView.alwaysBounceVertical = YES;
lockPositionsWebView.scrollView.alwaysBounceHorizontal = YES;
</code></pre>

<p><code>bounces</code> 属性必须为 <code>YES</code>,<code>alwaysBounceVertical</code> 和 <code>alwaysBounceHorizo​​ntal</code> 才能工作。</p>

<p>请参阅 Apple 的 <code>alwaysBounceHorizo​​ntal</code> 文档:</p>

<blockquote>
<p>A Boolean value that determines whether bouncing always occurs when
horizontal scrolling reaches the end of the content view.<br/>
If this property is set to YES <strong>and bounces is YES</strong>, horizontal dragging is
allowed even if the content is smaller than the bounds of the scroll
view. The default value is NO.</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UIWebView 水平反弹不起作用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/17354895/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/17354895/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UIWebView 水平反弹不起作用