ios动态切换logo不要弹框提示

给UIViewController添加一个category

#import "UIViewController+Util.h" 文件对应

#import <UIKit/UIKit.h>

@interface UIViewController (Util)

@end

#import "UIViewController+Util.m"文件

#import <objc/runtime.h>

@implementation UIViewController (Util)

+ (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(dy_presentViewController:animated:completion:));
       
        method_exchangeImplementations(presentM, presentSwizzlingM);
    });
}

- (void)dy_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
   
    if ([viewControllerToPresent isKindOfClass:[UIAlertController class]]) {
        NSLog(@"弹框标题 = title : %@",((UIAlertController *)viewControllerToPresent).title);
        NSLog(@"弹框内容 = message : %@",((UIAlertController *)viewControllerToPresent).message);
       
        UIAlertController *alertController = (UIAlertController *)viewControllerToPresent;
        if (alertController.title == nil && alertController.message == nil) {
            return;
        } else {
            [self dy_presentViewController:viewControllerToPresent animated:flag completion:completion];
            return;
        }
    }
   
    [self dy_presentViewController:viewControllerToPresent animated:flag completion:completion];
}

@end


然后在.pch文件中导入这个文件即可。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容