子线程push一个controller 引起的崩溃

感谢大佬给的解答

创建 UINavigationController+Main.h 文件

.h文件 

#import

NS_ASSUME_NONNULL_BEGIN

@interfaceUINavigationController (Main)

@end

NS_ASSUME_NONNULL_END

.m文件


#import "UINavigationController+Main.h"

#import

@implementationUINavigationController (Main)

+ (void)load {

    staticdispatch_once_tonceToken;

    dispatch_once(&onceToken, ^{

        MethodoriM =class_getInstanceMethod([selfclass],@selector(pushViewController:animated:));

        MethodrepM =class_getInstanceMethod([selfclass],@selector(p_pushViewController:animated:));

        method_exchangeImplementations(oriM, repM);

    });

}

- (void)p_pushViewController:(UIViewController*)viewController animated:(BOOL)animated {

    dispatch_async(dispatch_get_main_queue(), ^{

        [selfp_pushViewController:viewControlleranimated:animated];

    });

}

@end



其他的什么也不用动 

你可能感兴趣的:(子线程push一个controller 引起的崩溃)