UINavigationController+PushOneVC.m
946 Bytes
//
// UINavigationController+PushOneVC.m
// CNLiveScioLive
//
// Created by CNLive on 2021/8/27.
// Copyright © 2021 CNLive. All rights reserved.
//
#import "UINavigationController+PushOneVC.h"
#import <objc/runtime.h>
@implementation UINavigationController (PushOneVC)
+(void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method origin = class_getInstanceMethod(self, @selector(pushViewController:animated:));
Method new = class_getInstanceMethod(self, @selector(CN_pushViewController:animated:));
method_exchangeImplementations(origin, new);
});
}
-(void)CN_pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if ([self.viewControllers.lastObject isKindOfClass:[viewController class]]) {
return;
}
self.modalPresentationStyle = UIModalPresentationFullScreen;
[self CN_pushViewController:viewController animated:YES];
}
@end