菜鸟教程小白 发表于 2022-12-11 18:52:44

iOS11 滚动偏移 - 过渡问题


                                            <p><p>我正在开发一个应用程序,在 iOS 11 之后,自定义翻转卡转换无法正常工作。如果您查看下面的 GIF(故意放慢动画),您会看到卡片未正确放置在返回翻转上,然后“点击”到位。对于 iOS 10 及更低版本,这不会发生。无需点击即可返回到原来的位置。</p>

<p> <img src="/image/crW9n.gif" alt="GIF of animation"/> </p>

<p>我查看了新的 contentInsetAdjustmentBehaviour 并将其设置为 .never 以避免卡片和顶部状态栏之间的空间。然而这并没有解决问题。</p>

<pre><code>if (@available(iOS 11.0, *)) {
    self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    self.navigationController.navigationBar.prefersLargeTitles = NO;
    self.navigationController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
}
</code></pre>

<p>有人知道我应该从哪里解决这个问题吗?</p>

<p><strong>更新技巧</strong></p>

<p>我查看了过渡以及确定过渡中心的位置。在这里,我为 iOS 11 做了一个小技巧,将 iPhone 8+ 及以下版本的中心移动了 64 点,iPhone X 移动了 88 点。但只是在我还没有开始滚动的时候。如果我滚动中心在所有 iPhone 型号上移动了 44 个点。请参阅下面的临时解决方案:</p>

<pre><code>CGPoint targetCenterInContainer = CGPointMake(CGRectGetMidX(newCardFrame), CGRectGetMidY(newCardFrame));

if (@available(iOS 11.0, *)) {

    double offset = newCardFrame.origin.y - originalCardFrame.origin.y;

    if (offset == 64) {
      targetCenterInContainer.y -= 64; // For iPhone 8 Plus and below, with no scroll offset
    } else if (offset == 88) {
      targetCenterInContainer.y -= 88; // For iPhone X, with no scroll offset
    } else {
      targetCenterInContainer.y -= 44; // For when there are scroll offset, all iPhones
    }
}
</code></pre>

<p>这可以正常工作,但不是 100%。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我的应用程序的所有动画都面临类似的问题,转换后的某些组件放错了位置,所以我的建议只是禁用 ios 11 版本的动画我的意思是在苹果解决所有这些问题之前将动画值设置为 false。</p ></p>
                                   
                                                <p style="font-size: 20px;">关于iOS11 滚动偏移 - 过渡问题,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/46525077/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/46525077/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS11 滚动偏移 - 过渡问题