Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 14 Beta 6 开启 customNavigationBarTransitionKey 的情况下转场效果错误 #1081

Closed
MoLice opened this issue Aug 28, 2020 · 9 comments
Labels

Comments

@MoLice
Copy link
Collaborator

MoLice commented Aug 28, 2020

Bug 表现

预期的表现

Bug 原因

——by tibbers

iOS 14 Beta 6 开始,UINavigationBar 无法直接初始化后使用,必须关联在某个 UINavigationController 里,否则内部的 subviews 不会被创建出来,而 QMUI customNavigationBarTransitionKey 的工作方式就是在转场时把原来的 bar 的背景去除,再创建两条假 bar 模拟前后两个界面的样式,由于这两条假 bar 没有关联的 UINavigationController,所以内部 subviews 为空,所以转场时可以看到整个顶部导航栏的背景都是空的。

暂时的修复方式是重写假 bar 的 _accessibility_navigationController 方法,返回原始 bar 的同名方法的值,这样系统就会认为假 bar 存在关联的 UINavigationController,表现就正常了。

其他信息

  • 设备: [All]
  • iOS 版本: [iOS 14.0 Beta 6]
  • Xcode 版本: [Xcode 12 Beta 6]
  • QMUI 版本: [4.2.0]
@GUIYIVIEW-Maybe
Copy link

你好,请问_accessibility_navigationController这个代表是哪个方法?

@Liaoworking
Copy link

你好,请问_accessibility_navigationController这个代表是哪个方法?

UINavigationBar的一个系统私有方法

@GUIYIVIEW-Maybe
Copy link

你好,请问_accessibility_navigationController这个代表是哪个方法?

UINavigationBar的一个系统私有方法

感谢!!!

@ZFBest
Copy link

ZFBest commented Sep 17, 2020

感恩!

@MoLice
Copy link
Collaborator Author

MoLice commented Sep 18, 2020

在 4.2.1 发布前,如需要,可将以下方法添加到 @implementation _QMUITransitionNavigationBar 里,来修复这个 issue。

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        // iOS 14 开启 customNavigationBarTransitionKey 的情况下转场效果错误
        // https://github.com/Tencent/QMUI_iOS/issues/1081
        if (@available(iOS 14.0, *)) {
            OverrideImplementation([_QMUITransitionNavigationBar class], NSSelectorFromString([NSString stringWithFormat:@"_%@_%@", @"accessibility", @"navigationController"]), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
                return ^UINavigationController *(_QMUITransitionNavigationBar *selfObject) {
                    if (selfObject.originalNavigationBar) {
                        BeginIgnorePerformSelectorLeaksWarning
                        return [selfObject.originalNavigationBar performSelector:originCMD];
                        EndIgnorePerformSelectorLeaksWarning
                    }
                    
                    // call super
                    UINavigationController *(*originSelectorIMP)(id, SEL);
                    originSelectorIMP = (UINavigationController *(*)(id, SEL))originalIMPProvider();
                    UINavigationController *result = originSelectorIMP(selfObject, originCMD);
                    return result;
                };
            });
        }
    });
}

@SwiftBMan
Copy link

4.2.0 最好各个版本测试一下,弹一闪😿

@MoLice MoLice changed the title iOS 14 Beta 6 开启 customNavigationBarTransitionKey 的情况下转场效果错误 [UIKit Bug] iOS 14 Beta 6 开启 customNavigationBarTransitionKey 的情况下转场效果错误 Sep 29, 2020
@MoLice MoLice changed the title [UIKit Bug] iOS 14 Beta 6 开启 customNavigationBarTransitionKey 的情况下转场效果错误 iOS 14 Beta 6 开启 customNavigationBarTransitionKey 的情况下转场效果错误 Sep 29, 2020
@MoLice
Copy link
Collaborator Author

MoLice commented Sep 29, 2020

已发布 4.2.1 修复该问题。

@MoLice MoLice closed this as completed Sep 29, 2020
@allen8300
Copy link

allen8300 commented Oct 10, 2020

你好,请问_accessibility_navigationController这个代表是哪个方法?

UINavigationBar的一个系统私有方法

感谢!!!

@MoLice @Liaoworking
请教一下,这个私有方法带上审核安全吗?不会有被拒的风险吗?急急急,辛苦👍

@Liaoworking
Copy link

Liaoworking commented Oct 10, 2020

你好,请问_accessibility_navigationController这个代表是哪个方法?

UINavigationBar的一个系统私有方法

感谢!!!

@MoLice @Liaoworking
请教一下,这个私有方法带上审核安全吗?不会有被拒的风险吗?急急急,辛苦👍

我们后来用的其他方法解决的导航栏显示异常的问题, 这个库用的人很多,如果有问题的话应该有人会说,勇敢点~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants