简体   繁体   English

iOS11滚动偏移-过渡问题

[英]iOS11 scroll offset - problems with transitions

I am working on an app where after iOS 11 a custom flip-card transition is not working correctly. 我正在开发一个应用程序,该应用程序在iOS 11之后自定义翻转卡过渡无法正常工作。 If you look at the GIF below (purposely slow animation) you can see that the card is not correctly placed on the return-flip, and afterwards "clicks" into place. 如果查看下面的GIF(特意为慢速动画),您会发现卡未正确放置在回程卡上,然后“咔嗒”一声到位。 With iOS 10 and below this doesn't happen. 在iOS 10及更低版本中,这不会发生。 It returns to its original place without the click. 无需单击即可返回到其原始位置。

动画的GIF

I have looked into the new contentInsetAdjustmentBehaviour and set this to .never to avoid the space between the cards and status bar on top. 我研究了新的contentInsetAdjustmentBehaviour并将其设置为.never,以避免卡和顶部状态栏之间的空间。 This however did not solve the problem. 但是,这不能解决问题。

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

Does anyone have any idea of where I should look to fix this problem? 有谁知道我应该在哪里解决该问题?

UPDATE HACK 更新黑客

I looked at the transition and where the center of the transition is determined. 我查看了过渡以及过渡中心的位置。 Here I made a small hack for iOS 11 that moved the center 64 points for iPhone 8+ and below and 88 points for iPhone X. But only when I had not started scrolling yet. 在这里,我为iOS 11做了一个小技巧,将iPhone 8+及以下的中心移动了64点,将iPhone X的中心移动了88点。但是只有当我还没有开始滚动时,才将​​其移动。 If I scrolled the center was moved 44 points on all iPhone models. 如果我滚动,则所有iPhone型号的中心都移动了44点。 See temporary solution below: 请参阅下面的临时解决方案:

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
    }
}

This works okay, but not 100%. 可以,但是不是100%。

我的应用程序中的所有动画都遇到了类似的问题,转换后某些组件的位置不正确,所以我的建议是禁用ios 11版本的动画,我的意思是将动画值设置为false,直到苹果解决所有这些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM