1234567891011121314151617181920212223242526272829303132333435 |
- //
- // UIViewController+RQChangeIconNoAlert.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/8/12.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "UIViewController+RQChangeIconNoAlert.h"
- #import <objc/runtime.h>
- @implementation UIViewController (RQChangeIconNoAlert)
- + (void)load {
-
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- Method presentM = class_getInstanceMethod(self.class, @selector(presentViewController:animated:completion:));
- Method presentSwizzlingM = class_getInstanceMethod(self.class, @selector(rq_presentViewController:animated:completion:));
-
- method_exchangeImplementations(presentM, presentSwizzlingM);
- });
- }
- - (void)rq_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
-
- if ([viewControllerToPresent isKindOfClass:[UIAlertController class]]) {
- UIAlertController *alertController = (UIAlertController *)viewControllerToPresent;
- if (alertController.title == nil && alertController.message == nil) {
- return;
- }
- }
-
- [self rq_presentViewController:viewControllerToPresent animated:flag completion:completion];
- }
- @end
|