UIViewController+RQChangeIconNoAlert.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // UIViewController+RQChangeIconNoAlert.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/12.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "UIViewController+RQChangeIconNoAlert.h"
  9. #import <objc/runtime.h>
  10. @implementation UIViewController (RQChangeIconNoAlert)
  11. + (void)load {
  12. static dispatch_once_t onceToken;
  13. dispatch_once(&onceToken, ^{
  14. Method presentM = class_getInstanceMethod(self.class, @selector(presentViewController:animated:completion:));
  15. Method presentSwizzlingM = class_getInstanceMethod(self.class, @selector(rq_presentViewController:animated:completion:));
  16. method_exchangeImplementations(presentM, presentSwizzlingM);
  17. });
  18. }
  19. - (void)rq_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
  20. if ([viewControllerToPresent isKindOfClass:[UIAlertController class]]) {
  21. UIAlertController *alertController = (UIAlertController *)viewControllerToPresent;
  22. if (alertController.title == nil && alertController.message == nil) {
  23. return;
  24. }
  25. }
  26. [self rq_presentViewController:viewControllerToPresent animated:flag completion:completion];
  27. }
  28. @end